Namespaces
Variants

std:: formatter <std::filesystem::path>

From cppreference.net
헤더 파일에 정의됨 <filesystem>
template < class CharT >
struct formatter < std:: filesystem :: path , CharT > ;
(C++26부터)

std::formatter 의 템플릿 특수화는 std::filesystem::path 클래스에 대해 사용자가 포맷팅 함수 를 사용하여 경로명을 텍스트 표현으로 변환할 수 있도록 합니다. 이 특수화는 디버그 활성화 상태입니다.

목차

형식 지정

형식 지정의 구문 path-format-spec 은 다음과 같습니다:

fill-and-align  (선택 사항) width  (선택 사항) ? (선택 사항) g (선택 사항)

fill-and-align width 표준 형식 지정 에서와 동일한 의미를 가집니다.

? 옵션은 경로명을 이스케이프된 문자열 로 포맷하는 데 사용됩니다.

g 옵션은 경로 이름이 일반 형식 표현 으로 되어 있음을 지정하는 데 사용됩니다.

멤버 함수

set_debug_format
경로명을 이스케이프된 문자열 로 포맷할 수 있도록 설정합니다
(public member function)
parse
path-format-spec 에 지정된 형식 지정자를 파싱합니다
(public member function)
format
path-format-spec 에 지정된 형식으로 출력을 작성합니다
(public member function)

std::formatter<std::filesystem::path>:: set_debug_format

constexpr void set_debug_format ( ) ;

현재 객체가 경로명을 이스케이프된 문자열 로 포맷팅할 수 있도록 합니다.

std::formatter<std::filesystem::path>:: parse

constexpr auto parse ( std:: basic_format_parse_context < CharT > & ctx )
- > std:: basic_format_parse_context < CharT > :: iterator ;

형식 지정자를 path-format-spec 으로 파싱하고 파싱된 지정자를 현재 객체에 저장합니다.

path-format-spec 의 끝을 지난 반복자를 반환합니다.

std::formatter<std::filesystem::path>:: format

template < class FormatContext >

auto format ( const std:: filesystem :: path & p, FormatContext & ctx ) const

- > FormatContext :: iterator ;

g 옵션이 사용된 경우 s p. generic < std :: filesystem :: path :: value_type > ( ) 로 설정하고, 그렇지 않으면 p. native ( ) 로 설정합니다. s path-format-spec 에 지정된 대로 ctx. out ( ) 에 기록합니다.

경로명의 문자 변환에 대해:

  • 다음 조건을 모두 만족하면 경로명이 와이드 문자 문자열의 네이티브 인코딩에서 UTF-8로 변환되며, 잘못된 서브시퀀스의 최대 부분은 U+FFFD REPLACEMENT CHARACTER로 대체됩니다:
  • 그렇지 않고 std:: is_same_v < typename path :: value_type , CharT > true 이면 변환은 수행되지 않습니다.
  • 그 외의 경우 변환은 구현에 따라 정의됩니다.

출력 범위의 끝을 지난 반복자를 반환합니다.

참고 사항

Feature-test 매크로 표준 기능
__cpp_lib_format_path 202403L (C++26) std::filesystem::path 에 대한 formatting 지원

예제

참고 항목

(C++20)
주어진 타입에 대한 서식 규칙을 정의함
(클래스 템플릿)