Files
2025-10-25 03:02:53 +03:00

100 lines
3.8 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[fs.path.fmtr]
# 31 Input/output library [[input.output]](./#input.output)
## 31.12 File systems [[filesystems]](filesystems#fs.path.fmtr)
### 31.12.6 Class path [[fs.class.path]](fs.class.path#fs.path.fmtr)
#### 31.12.6.9 Formatting support [fs.path.fmtr]
#### [31.12.6.9.1](#general) Formatting support overview [[fs.path.fmtr.general]](fs.path.fmtr.general)
[🔗](#lib:formatter)
namespace std {template<class charT> struct formatter<filesystem::path, charT> {constexpr void set_debug_format(); constexpr typename basic_format_parse_context<charT>::iterator
parse(basic_format_parse_context<charT>& ctx); template<class FormatContext>typename FormatContext::iterator
format(const filesystem::path& path, FormatContext& ctx) const; };}
#### [31.12.6.9.2](#funcs) Formatting support functions [[fs.path.fmtr.funcs]](fs.path.fmtr.funcs)
[1](#funcs-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15483)
Formatting of paths uses formatting specifiers of the form
[path-format-spec:](#nt:path-format-spec "31.12.6.9.2Formatting support functions[fs.path.fmtr.funcs]")
fill-and-alignopt widthopt ?opt gopt
where the productions *fill-and-align* and *width* are described in [[format.string]](format.string "28.5.2Format string")[.](#funcs-1.sentence-1)
If the ? option is used then
the path is formatted as an escaped string ([[format.string.escaped]](format.string.escaped "28.5.6.5Formatting escaped characters and strings"))[.](#funcs-1.sentence-2)
[🔗](#lib:formatter,set_debug_format)
`constexpr void set_debug_format();
`
[2](#funcs-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15500)
*Effects*: Modifies the state of the formatter to be as if
the *path-format-spec* parsed by the last call to parse contained the ? option[.](#funcs-2.sentence-1)
[🔗](#lib:formatter,basic_format_parse_context)
`constexpr typename basic_format_parse_context<charT>::iterator
parse(basic_format_parse_context<charT>& ctx);
`
[3](#funcs-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15514)
*Effects*: Parses the format specifier as a *path-format-spec* and
stores the parsed specifiers in *this[.](#funcs-3.sentence-1)
[4](#funcs-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15519)
*Returns*: An iterator past the end of the *path-format-spec*[.](#funcs-4.sentence-1)
[🔗](#lib:formatter,format)
`template<class FormatContext>
typename FormatContext::iterator
format(const filesystem::path& p, FormatContext& ctx) const;
`
[5](#funcs-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15532)
*Effects*: Let s be p.generic_string<filesystem::path::value_type>() if the g option is used,
otherwise p.native()[.](#funcs-5.sentence-1)
Writes s into ctx.out(),
adjusted according to the *path-format-spec*[.](#funcs-5.sentence-2)
If charT is char,path::value_type is wchar_t, and
the literal encoding is UTF-8,
then the escaped path is transcoded from the native encoding for
wide character strings to UTF-8 with
maximal subparts of ill-formed subsequences
substituted with U+fffd replacement character per the Unicode Standard, Chapter 3.9 U+fffd Substitution in Conversion[.](#funcs-5.sentence-3)
If charT and path::value_type are the same
then no transcoding is performed[.](#funcs-5.sentence-4)
Otherwise, transcoding isimplementation-defined[.](#funcs-5.sentence-5)
[6](#funcs-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15552)
*Returns*: An iterator past the end of the output range[.](#funcs-6.sentence-1)