FreeBSD Manual Pages
std::messages_byname(3) C++ Standard Libary std::messages_byname(3) NAME std::messages_byname - std::messages_byname Synopsis Defined in header <locale> template< class CharT > class messages_byname : public std::messages<CharT>; std::messages_byname is a std::messages facet which encapsulates re- trieval of strings from message catalogs of the locale specified at its con- struction. Two specializations are provided by the standard library Defined in header <locale> std::messages_byname<char> narrow/multibyte message catalog ac- cess std::messages_byname<wchar_t> wide string message catalog access Member types Member type Definition catalog std::messages_base<CharT>::catalog string_type std::basic_string<CharT> Member functions constructor constructs a new messages_byname facet (public member function) destructor destroys a messages_byname facet (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 = (since C++11) 0 ); Constructs a new std::messages_byname facet for a locale with name. refs is used for resource management: if refs == 0, the implementa- tion destroys the facet, when the last std::locale object holding it is destroyed. Otherwise, the object is not destroyed. Parameters name - the name of the locale refs - the number of references that link to the facet std::messages_byname::~messages_byname protected: ~messages_byname(); Destroys the facet. Inherited from std::messages Member types Member type Definition char_type charT string_type std::basic_string<charT> Member objects Member name Type id (static) std::locale::id Member functions open invokes do_open (public member function of std::messages<CharT>) get invokes do_get (public member function of std::messages<CharT>) close invokes do_close (public member function of std::messages<CharT>) Protected member functions do_open opens a named message catalog [virtual] (virtual protected member function of std::mes- sages<CharT>) do_get retrieves a message from an open message catalog [virtual] (virtual protected member function of std::mes- sages<CharT>) do_close closes a message catalog [virtual] (virtual protected member function of std::mes- sages<CharT>) Example // Run this code #include <iostream> #include <locale> void try_with(const std::locale& loc) { const std::messages<char>& facet = std::use_facet<std::mes- sages<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_by- name<char>("de_DE.utf8"))); try_with(std::locale(loc, new std::messages_by- name<char>("fr_FR.utf8"))); try_with(std::locale(loc, new std::messages_by- name<char>("ja_JP.utf8"))); } Possible output: "No match" Keine bereinstimmung "Memory exhausted" Speicher erschpft "No match" Pas de concordance "Memory exhausted" Mmoire puise "No match" "Memory exhausted" See also messages implements retrieval of strings from message catalogs (class template) http://cppreference.com 2022.07.31 std::messages_byname(3)
NAME | Synopsis | Member types | Member functions | Parameters | Member types | Member objects | Member functions | Protected member functions | Example | Possible output: | See also
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::messages_byname&sektion=3&manpath=FreeBSD+Ports+15.0>
