Share via


basic_path Class

Defines a class that stores an object of template type String that's suitable for use as a file name.

template<class String, class Traits>
class basic_path;

Remarks

The library defines specializations of this template for two types.

basic_path<string, path_traits>, with the typedefpath, uses std::string and the path_traits structure.

basic_path<wstring, wpath_traits>, with the typedefwpath, uses std::wstring and the wpath_traits structure.

You can use an object of type path wherever an argument of type std::string is acceptable as a file name.

std::tr2::sys::path myfile(“abc.txt”);
std::ofstream ofs(myfile);
ofs << “hello\n”;
ofs.close();

Similarly, you can use an object of type wpath wherever an argument of type std::wstring is acceptable as a file name.

A stored file name consists of an optional prefix, followed by an optional root, followed by an optional relative path.

  • A prefix consists of all elements that lead up to and include the first colon.

  • A root consists of one slash.

  • A relative path consists of one or more path elements that are delimited by sequences of slashes.

A file name iterator that is returned by basic_path::begin designates the first filename component.

A filename iterator X implies the following.

  • X == end() indicates the end of the sequence of filename components.

  • *X returns a string that matches the current component.

  • ++X designates the next component, if present.

  • --X designates the preceding component, if present.

Members

Public Typedefs

Name

Description

basic_path::const_iterator

A synonym for basic_path::iterator.

basic_path::external_string_type

A synonym for Traits::external_string_type.

basic_path::iterator

Describes a filename iterator that can serve as a bi-directional iterator over the components of the stored file name.

basic_path::path_type

A synonym for basic_path<String, Traits>.

basic_path::string_type

A synonym for the String template parameter.

basic_path::traits_type

A synonym for the Traits template parameter.

basic_path::value_type

A synonym for String::value_type.

Public Constructors

Name

Description

basic_path::basic_path Constructor

Constructs a basic_path object.

Public Methods

Name

Description

basic_path::append Method

Appends elements to the stored file name.

basic_path::assign Method

Uses a specified set of elements to replace the stored file name.

basic_path::basename Method

Returns the substring of leaf up to but not including the rightmost dot.

basic_path::begin Method

Specifies the first component of the stored file name.

basic_path::branch_path Method

Retrieves the parent path of the basic_path object.

basic_path::clear Method

Clears the stored filename string.

basic_path::directory_string Method

Returns the stored file name.

basic_path::empty Method

Specifies whether the filename string is empty.

basic_path::end Method

Returns a filename iterator just beyond the last component in the stored file name.

basic_path::extension Method

Returns the extension of the stored file name, if it exists.

basic_path::external_directory_string Method

Converts the stored directory_string to the external_string_type.

basic_path::external_file_string Method

Converts the stored file_string to the external_string_type.

basic_path::file_string Method

Returns the stored file name.

basic_path::filename Method

Retrieves the stored file name.

basic_path::has_branch_path Method

Specifies whether the stored file name contains a branch path.

basic_path::has_filename Method

Specifies whether the stored string contains a file name.

basic_path::has_leaf Method

Specifies whether the stored file name contains a leaf.

basic_path::has_parent_path Method

Specifies whether the stored file name contains a parent path.

basic_path::has_relative_path Method

Specifies whether the stored file name contains a relative path.

basic_path::has_root_directory Method

Specifies whether the stored file name contains a root directory.

basic_path::has_root_name Method

Specifies whether the stored file name contains a root name.

basic_path::has_root_path Method

Specifies whether the stored file name contains a root path.

basic_path::is_complete Method

Specifies whether the stored file name is complete.

basic_path::leaf Method

Retrieves the stored file name.

basic_path::parent_path Method

Retrieves the parent path of the basic_path object.

basic_path::relative_path Method

Retrieves the relative path of the stored file name.

basic_path::remove_filename Method

Removes the last path element in the relative path, if it exists.

basic_path::remove_leaf Method

Removes the last path element in the relative path, if it exists.

basic_path::replace_extension Method

Replaces the file name extension of the stored file name.

basic_path::root_directory Method

Returns the root, if it exists.

basic_path::root_name Method

Returns the prefix, if it exists.

basic_path::root_path Method

Retrieves the root path of the stored file name.

basic_path::stem Method

Returns the substring of leaf up to but not including the rightmost dot.

basic_path::string Method

Returns the stored file name.

basic_path::swap Method

Swaps the stored file name with the file name from a specified basic_path object.

Public Operators

Name

Description

basic_path::operator string_type Operator

Returns the stored file name.

basic_path::operator/= Operator

Appends a series of elements to the stored file name.

basic_path::operator= Operator

Assigns a new value to the stored file name.

Requirements

Header: filesystem

Namespace: std::tr2::sys

See Also

Reference

<filesystem>

Other Resources

Header Files