GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::messages::open,std::messages::do_open(3) C++ Standard Libary std::messages::open,std::messages::do_open(3)

std::messages::open,std::messages::do_open - std::messages::open,std::messages::do_open


Defined in header <locale>
public:
catalog open( const std::basic_string<char>& name, const std::locale& loc ) (1)
const;
protected:
virtual catalog do_open( const std::basic_string<char>& name, const (2)
std::locale& loc ) const;


1) Public member function, calls the protected virtual member function do_open of
the most derived class.


2) Obtains a value of type catalog (inherited from std::messages_base), which can be
passed to get() to retrieve messages from the message catalog named by name. This
value is usable until passed to close().


name - name of the message catalog to open
a locale object that provides additional facets that may be required to read
loc - messages from the catalog, such as std::codecvt to perform wide/multibyte
conversions


The non-negative value of type catalog that can be used with get() and close().
Returns a negative value if the catalog could not be opened.


On POSIX systems, this function call usually translates to a call to catopen(). In
GNU libstdc++, it calls textdomain.


The actual catalog location is implementation-defined: for the catalog "sed"
(message catalogs installed with the Unix utility 'sed') in German locale, for
example, the file opened by this function call may be
/usr/lib/nls/msg/de_DE/sed.cat, /usr/lib/locale/de_DE/LC_MESSAGES/sed.cat, or
/usr/share/locale/de/LC_MESSAGES/sed.mo.


The following example demonstrated retrieval of messages: on a typical GNU/Linux
system it reads from /usr/share/locale/de/LC_MESSAGES/sed.mo

// Run this code


#include <iostream>
#include <locale>


int main()
{
std::locale loc("de_DE.utf8");
std::cout.imbue(loc);
auto& facet = std::use_facet<std::messages<char>>(loc);
auto cat = facet.open("sed", loc);
if(cat < 0 )
std::cout << "Could not open german \"sed\" message catalog\n";
else
std::cout << "\"No match\" in German: "
<< facet.get(cat, 0, 0, "No match") << '\n'
<< "\"Memory exhausted\" in German: "
<< facet.get(cat, 0, 0, "Memory exhausted") << '\n';
facet.close(cat);
}


"No match" in German: Keine Übereinstimmung
"Memory exhausted" in German: Speicher erschöpft

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.