|
13456 | 13456 | path weakly_canonical(const path& p, error_code& ec);
|
13457 | 13457 | }
|
13458 | 13458 |
|
13459 |
| -// \ref{fs.path.hash}, hash support |
13460 | 13459 | namespace std {
|
| 13460 | + // \ref{fs.path.fmtr}, formatting support |
| 13461 | + template<class charT> struct formatter<filesystem::path, charT>; |
| 13462 | + |
| 13463 | + // \ref{fs.path.hash}, hash support |
13461 | 13464 | template<class T> struct hash;
|
13462 | 13465 | template<> struct hash<filesystem::path>;
|
13463 | 13466 | }
|
@@ -15412,6 +15415,102 @@
|
15412 | 15415 | Equivalent to: \tcode{return path(lhs) /= rhs;}
|
15413 | 15416 | \end{itemdescr}
|
15414 | 15417 |
|
| 15418 | +\rSec3[fs.path.fmtr]{Formatting support} |
| 15419 | + |
| 15420 | +\rSec4[fs.path.fmtr.general]{Formatting support overview} |
| 15421 | + |
| 15422 | +\indexlibraryglobal{formatter}% |
| 15423 | +\begin{codeblock} |
| 15424 | +namespace std { |
| 15425 | + template<class charT> struct formatter<filesystem::path, charT> { |
| 15426 | + constexpr void set_debug_format(); |
| 15427 | + |
| 15428 | + constexpr typename basic_format_parse_context<charT>::iterator |
| 15429 | + parse(basic_format_parse_context<charT>& ctx); |
| 15430 | + |
| 15431 | + template<class FormatContext> |
| 15432 | + typename FormatContext::iterator |
| 15433 | + format(const filesystem::path& path, FormatContext& ctx) const; |
| 15434 | + }; |
| 15435 | +} |
| 15436 | +\end{codeblock} |
| 15437 | + |
| 15438 | +\pnum |
| 15439 | +Formatting of paths uses formatting specifiers of the form |
| 15440 | +\begin{ncbnf} |
| 15441 | +\nontermdef{path-format-spec}\br |
| 15442 | + \opt{fill-and-align} \opt{width} \opt{\terminal{?}} \opt{\terminal{g}} |
| 15443 | +\end{ncbnf} |
| 15444 | +where the productions \fmtgrammarterm{fill-and-align} and \fmtgrammarterm{width} |
| 15445 | +are described in \ref{format.string}. |
| 15446 | +If the \tcode{?} option is used then |
| 15447 | +the path is formatted as an escaped string\iref{format.string.escaped}. |
| 15448 | + |
| 15449 | +\rSec4[fs.path.fmtr.funcs]{Formatting support functions} |
| 15450 | + |
| 15451 | +\indexlibrarymember{formatter}{set_debug_format}% |
| 15452 | +\begin{itemdecl} |
| 15453 | +constexpr void set_debug_format(); |
| 15454 | +\end{itemdecl} |
| 15455 | + |
| 15456 | +\begin{itemdescr} |
| 15457 | +\pnum |
| 15458 | +\effects |
| 15459 | +Modifies the state of the \tcode{formatter} to be as if |
| 15460 | +the \fmtgrammarterm{path-format-spec} parsed by the last call to \tcode{parse} |
| 15461 | +contained the \tcode{?} option. |
| 15462 | +\end{itemdescr} |
| 15463 | + |
| 15464 | +\indexlibrarymember{formatter}{basic_format_parse_context}% |
| 15465 | +\begin{itemdecl} |
| 15466 | +constexpr typename basic_format_parse_context<charT>::iterator |
| 15467 | + parse(basic_format_parse_context<charT>& ctx); |
| 15468 | +\end{itemdecl} |
| 15469 | + |
| 15470 | +\begin{itemdescr} |
| 15471 | +\pnum |
| 15472 | +\effects |
| 15473 | +Parses the format specifier as a \fmtgrammarterm{path-format-spec} and |
| 15474 | +stores the parsed specifiers in \tcode{*this}. |
| 15475 | + |
| 15476 | +\pnum |
| 15477 | +\returns |
| 15478 | +An iterator past the end of the \fmtgrammarterm{path-format-spec}. |
| 15479 | +\end{itemdescr} |
| 15480 | + |
| 15481 | +\indexlibrarymember{formatter}{format}% |
| 15482 | +\begin{itemdecl} |
| 15483 | +template<class FormatContext> |
| 15484 | + typename FormatContext::iterator |
| 15485 | + format(const filesystem::path& p, FormatContext& ctx) const; |
| 15486 | +\end{itemdecl} |
| 15487 | + |
| 15488 | +\begin{itemdescr} |
| 15489 | +\pnum |
| 15490 | +\effects |
| 15491 | +Let \tcode{s} be \tcode{p.generic_string<filesystem::path::value_type>()} |
| 15492 | +if the \tcode{g} option is used, |
| 15493 | +otherwise \tcode{p.native()}. |
| 15494 | +Writes \tcode{s} into \tcode{ctx.out()}, |
| 15495 | +adjusted according to the \fmtgrammarterm{path-format-spec}. |
| 15496 | +If \tcode{charT} is \keyword{char}, |
| 15497 | +\tcode{path::value_type} is \keyword{wchar_t}, and |
| 15498 | +the literal encoding is UTF-8, |
| 15499 | +then the escaped path is transcoded from the native encoding for |
| 15500 | +wide character strings to UTF-8 with |
| 15501 | +maximal subparts of ill-formed subsequences |
| 15502 | +substituted with \ucode{fffd} \uname{replacement character} |
| 15503 | +per the Unicode Standard, Chapter 3.9 \ucode{fffd} Substitution in Conversion. |
| 15504 | +If \tcode{charT} and \tcode{path::value_type} are the same |
| 15505 | +then no transcoding is performed. |
| 15506 | +Otherwise, transcoding is |
| 15507 | +\impldef{transcoding of the escaped path when \tcode{charT} and \tcode{path::value_type} differ}. |
| 15508 | + |
| 15509 | +\pnum |
| 15510 | +\returns |
| 15511 | +An iterator past the end of the output range. |
| 15512 | +\end{itemdescr} |
| 15513 | + |
15415 | 15514 | \rSec3[fs.path.hash]{Hash support}
|
15416 | 15515 |
|
15417 | 15516 | \begin{itemdecl}
|
|
0 commit comments