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 |
---|---|
Constructs a basic_path object. |
Public Methods
Name |
Description |
---|---|
Appends elements to the stored file name. |
|
Uses a specified set of elements to replace the stored file name. |
|
Returns the substring of leaf up to but not including the rightmost dot. |
|
Specifies the first component of the stored file name. |
|
Retrieves the parent path of the basic_path object. |
|
Clears the stored filename string. |
|
Returns the stored file name. |
|
Specifies whether the filename string is empty. |
|
Returns a filename iterator just beyond the last component in the stored file name. |
|
Returns the extension of the stored file name, if it exists. |
|
Converts the stored directory_string to the external_string_type. |
|
Converts the stored file_string to the external_string_type. |
|
Returns the stored file name. |
|
Retrieves the stored file name. |
|
Specifies whether the stored file name contains a branch path. |
|
Specifies whether the stored string contains a file name. |
|
Specifies whether the stored file name contains a leaf. |
|
Specifies whether the stored file name contains a parent path. |
|
Specifies whether the stored file name contains a relative path. |
|
Specifies whether the stored file name contains a root directory. |
|
Specifies whether the stored file name contains a root name. |
|
Specifies whether the stored file name contains a root path. |
|
Specifies whether the stored file name is complete. |
|
Retrieves the stored file name. |
|
Retrieves the parent path of the basic_path object. |
|
Retrieves the relative path of the stored file name. |
|
Removes the last path element in the relative path, if it exists. |
|
Removes the last path element in the relative path, if it exists. |
|
Replaces the file name extension of the stored file name. |
|
Returns the root, if it exists. |
|
Returns the prefix, if it exists. |
|
Retrieves the root path of the stored file name. |
|
Returns the substring of leaf up to but not including the rightmost dot. |
|
Returns the stored file name. |
|
Swaps the stored file name with the file name from a specified basic_path object. |
Public Operators
Name |
Description |
---|---|
Returns the stored file name. |
|
Appends a series of elements to the stored file name. |
|
Assigns a new value to the stored file name. |
Requirements
Header: filesystem
Namespace: std::tr2::sys