Namespaces
Variants

std:: messages_byname

From cppreference.net
헤더에 정의됨 <locale>
template < class CharT >
class messages_byname : public std:: messages < CharT > ;

std::messages_byname 는 생성 시 지정된 로캘의 메시지 카탈로그에서 문자열을 검색하는 기능을 캡슐화하는 std::messages 패싯입니다.

목차

특수화

표준 라이브러리는 다음과 같은 특수화를 제공함을 보장합니다:

헤더 파일에 정의됨 <locale>
std :: messages_byname < char > 좁은/멀티바이트 메시지 카탈로그 접근
std :: messages_byname < wchar_t > 와이드 문자열 메시지 카탈로그 접근

중첩 타입

유형 정의
catalog std:: messages_base < CharT > :: catalog
string_type std:: basic_string < CharT >

멤버 함수

(constructor)
새로운 messages_byname 패싯을 생성합니다
(public member function)
(destructor)
messages_byname 패싯을 파괴합니다
(protected member function)

std::messages_byname:: messages_byname

explicit messages_byname ( const char * name, std:: size_t refs = 0 ) ;
explicit messages_byname ( const std:: string & name, std:: size_t refs = 0 ) ;
(C++11 이후)

std::messages_byname 패싯을 name 로케일에 대해 새로 생성합니다.

refs 는 리소스 관리에 사용됩니다: refs == 0 이면, 구현은 이 패싯을 포함하는 마지막 std::locale 객체가 소멸될 때 패싯을 파괴합니다. 그렇지 않으면 객체는 파괴되지 않습니다.

매개변수

name - 로케일의 이름
refs - 패싯에 연결된 참조 횟수

std::messages_byname:: ~messages_byname

protected :
~messages_byname ( ) ;

해당 facet을 파괴합니다.

std:: messages 로부터 상속됨

중첩 타입

타입 정의
char_type CharT
string_type std:: basic_string < CharT >

데이터 멤버

멤버 설명
std::locale::id id [static] 패싯 의 식별자

멤버 함수

do_open 을 호출함
( std::messages<CharT> 의 public 멤버 함수)
do_get 을 호출함
( std::messages<CharT> 의 public 멤버 함수)
do_close 을 호출함
( std::messages<CharT> 의 public 멤버 함수)

보호된 멤버 함수

[virtual]
명명된 메시지 카탈로그를 염
( std::messages<CharT> 의 virtual protected 멤버 함수)
[virtual]
열린 메시지 카탈로그에서 메시지를 검색함
( std::messages<CharT> 의 virtual protected 멤버 함수)
[virtual]
메시지 카탈로그를 닫음
( std::messages<CharT> 의 virtual protected 멤버 함수)

std::messages_base로부터 상속됨

중첩 타입

타입 정의
catalog 지정되지 않은 부호 있는 정수 타입

예제

#include <iostream>
#include <locale>
void try_with(const std::locale& loc)
{
    const std::messages<char>& facet = std::use_facet<std::messages<char>>(loc);
    std::messages<char>::catalog cat = facet.open("sed", std::cout.getloc());
    if (cat < 0)
        std::cout << "Could not open \"sed\" message catalog\n";
    else
        std::cout << "\"No match\" "
                  << facet.get(cat, 0, 0, "No match") << '\n'
                  << "\"Memory exhausted\" " 
                  << facet.get(cat, 0, 0, "Memory exhausted") << '\n';
    facet.close(cat);
}
int main()
{
    std::locale loc("en_US.utf8");
    std::cout.imbue(loc);
    try_with(std::locale(loc, new std::messages_byname<char>("de_DE.utf8")));
    try_with(std::locale(loc, new std::messages_byname<char>("fr_FR.utf8")));
    try_with(std::locale(loc, new std::messages_byname<char>("ja_JP.utf8")));
}

가능한 출력:

"No match" Keine Übereinstimmung
"Memory exhausted" Speicher erschöpft
"No match" Pas de concordance
"Memory exhausted" Mémoire épuisée
"No match" 照合しません
"Memory exhausted" メモリーが足りません

참고 항목

메시지 카탈로그로부터 문자열 검색을 구현함
(클래스 템플릿)