basic_path 类

定义这些模板存储类型 String 对象应用作为文件名的类。

template<class String, class Traits>
class basic_path;

备注

库定义了此模板的专用化两个类型。

basic_path<string, path_traits>,与 typedef 使用 pathstd::string 和结构。path_traits

basic_path<wstring, wpath_traits>,与 typedef 使用 wpathstd::wstring 和结构。wpath_traits

可以使用类型 path 对象,无论类型 std::string 的参数是可作为文件名。

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

同样,可以使用类型 wpath 对象,无论类型 std::wstring 的参数是可作为文件名。

已存储"文件名包含一前缀选项,后跟一根选项,后跟一选项相对路径。

  • 前缀包括主管和包括第一个冒号应的所有元素。

  • 根包含一个斜杠。

  • 相对路径由斜杠分隔序列的一个或多个路径元素。

basic_path::begin 返回的文件名迭代器指定第一种组件。

文件名迭代器 X 意味着下列。

  • 文件名组成X == end() 指示序列的结尾。

  • *X 返回与当前组件的字符串。

  • 如果有++X 指定下,组件。

  • 如果--X 具有前面选定的组件,通常为。

成员

公共 Typedef

Name

说明

basic_path::const_iterator

basic_path::iterator的同义词.

basic_path::external_string_type

Traits::external_string_type的同义词.

basic_path::iterator

描述可以充当存储的文件名组件的双向迭代器的文件名迭代器。

basic_path::path_type

basic_path<String, Traits>的同义词.

basic_path::string_type

String 模板参数的同义词。

basic_path::traits_type

Traits 模板参数的同义词。

basic_path::value_type

String::value_type的同义词.

公共构造函数

Name

说明

basic_path::basic_path 构造函数

构造 basic_path 对象。

公共方法

Name

说明

basic_path::append 方法

追加元素给存储的文件名。

basic_path::assign 方法

指定使用的元素集替换存储的文件名。

basic_path::basename 方法

叶节点 等于返回子字符串但不包含最右边的点。

basic_path::begin 方法

指定的文件名的第一个组件。

basic_path::branch_path 方法

检索 basic_path 对象的父级的路径。

basic_path::clear 方法

清除存储文件名的字符串。

basic_path::directory_string 方法

返回存储的文件名。

basic_path::empty 方法

指定文件名字符串是否为空。

basic_path::end 方法

返回一个在存储文件名最后一个组件之外“文件名迭代器” 。

basic_path::extension 方法

如果该文件存在,返回存储的文件的扩展名。

basic_path::external_directory_string 方法

转换所存储的 directory_stringexternal_string_type

basic_path::external_file_string 方法

转换所存储的 file_stringexternal_string_type

basic_path::file_string 方法

返回存储的文件名。

basic_path::filename 方法

检索存储的文件名。

basic_path::has_branch_path 方法

存储指定的文件名是否包含分支路径。

basic_path::has_filename 方法

指定用于存储字符串是否包含一个文件名。

basic_path::has_leaf 方法

存储指定的文件名是否包含一个对象。

basic_path::has_parent_path 方法

指定的文件名是否包含一个存储父路径。

basic_path::has_relative_path 方法

存储指定的文件名是否包含相对路径。

basic_path::has_root_directory 方法

存储指定的文件名是否包含一个根目录。

basic_path::has_root_name 方法

指定的文件名是否包含一根名称。

basic_path::has_root_path 方法

指定的文件名是否包含一根路径。

basic_path::is_complete 方法

存储指定的文件名是否完成。

basic_path::leaf 方法

检索存储的文件名。

basic_path::parent_path 方法

检索 basic_path 对象的父级的路径。

basic_path::relative_path 方法

检索该存储的文件名的“相对路径” 。

basic_path::remove_filename 方法

如果该文件存在,在相对路径路径中移除最后一个元素。

basic_path::remove_leaf 方法

如果该文件存在,在相对路径路径中移除最后一个元素。

basic_path::replace_extension 方法

替换存储的文件的文件扩展名。

basic_path::root_directory 方法

如果根存在,则返回“根” 。

basic_path::root_name 方法

如果它存在,则返回“前缀” 。

basic_path::root_path 方法

检索存储的文件名的 根路径。

basic_path::stem 方法

叶节点 等于返回子字符串但不包含最右边的点。

basic_path::string 方法

返回存储的文件名。

basic_path::swap 方法

交换使用文件名的存储文件名从指定的 basic_path 对象。

公共运算符

Name

说明

basic_path::operator string_type 运算符

返回存储的文件名。

basic_path::operator/= Operator

附加一系列元素存储为的文件名。

basic_path::operator= 运算符

分配新值存储为的文件名。

要求

标头: filesystem

命名空间: std::tr2::sys

请参见

参考

<filesystem>

其他资源

C++ 标准库头文件