The locale class is first a class wrapper for C library locales. It is also an extensible container for user-defined localization. A locale is a collection of facets that implement various localization features such as money, time, and number printing.
Constructing C++ locales does not change the C library locale.
This library supports efficient construction and copying of locales through a reference counting implementation of the locale class.
Definition at line 66 of file locale_classes.h.
typedef int std::locale::category |
std::locale::locale | ( | ) | throw () |
std::locale::locale | ( | const locale & | __other | ) | throw () |
std::locale::locale | ( | const char * | __s | ) | [explicit] |
Named locale constructor.
Constructs a copy of the named C library locale.
s | Name of the locale to construct. |
std::runtime_error | if s is null or an undefined locale. |
Construct locale with facets from another locale.
Constructs a copy of the locale base. The facets specified by cat are replaced with those from the locale named by s. If base is named, this locale instance will also be named.
base | The locale to copy. | |
s | Name of the locale to use facets from. | |
cat | Set of categories defining the facets to use from s. |
std::runtime_error | if s is null or an undefined locale. |
std::locale::locale | ( | const locale & | __other, | |
_Facet * | __f | |||
) | [inline] |
std::locale::~locale | ( | ) | throw () |
Locale destructor.
Construct locale with another facet.
Constructs and returns a new copy of this locale. Adds or replaces an existing facet of type Facet from the locale other into the new locale.
std::runtime_error | if other has no facet of type Facet. |
Definition at line 66 of file locale_classes.tcc.
bool std::locale::operator!= | ( | const locale & | __other | ) | const throw () [inline] |
Locale inequality.
other | The locale to compare against. |
Definition at line 238 of file locale_classes.h.
References __gnu_cxx::operator==().
bool std::locale::operator() | ( | const basic_string< _CharT, _Traits, _Alloc > & | __s1, | |
const basic_string< _CharT, _Traits, _Alloc > & | __s2 | |||
) | const [inline] |
Compare two strings according to collate.
Template operator to compare two strings using the compare function of the collate facet in this locale. One use is to provide the locale to the sort function. For example, a vector v of strings could be sorted according to locale loc by doing:
std::sort(v.begin(), v.end(), loc);
s1 | First string to compare. | |
s2 | Second string to compare. |
Definition at line 84 of file locale_classes.tcc.
References std::basic_string< _CharT, _Traits, _Alloc >::data(), and std::basic_string< _CharT, _Traits, _Alloc >::length().
bool std::locale::operator== | ( | const locale & | __other | ) | const throw () |
bool has_facet | ( | const locale & | ) | throw () [friend] |
const _Facet& use_facet | ( | const locale & | ) | [friend] |
Return a facet.
use_facet looks for and returns a reference to a facet of type Facet where Facet is the template parameter. If has_facet(locale) is true, there is a suitable facet to return. It throws std::bad_cast if the locale doesn't contain a facet of type Facet.
std::bad_cast | if locale doesn't contain a facet of type Facet. |
const category std::locale::all [static] |
Category values.
The standard category values are none, ctype, numeric, collate, time, monetary, and messages. They form a bitmask that supports union and intersection. The category all is the union of these values.
NB: Order must match _S_facet_categories definition in locale.cc
Definition at line 109 of file locale_classes.h.
const category std::locale::collate [static] |
Category values.
The standard category values are none, ctype, numeric, collate, time, monetary, and messages. They form a bitmask that supports union and intersection. The category all is the union of these values.
NB: Order must match _S_facet_categories definition in locale.cc
Definition at line 105 of file locale_classes.h.
const category std::locale::ctype [static] |
Category values.
The standard category values are none, ctype, numeric, collate, time, monetary, and messages. They form a bitmask that supports union and intersection. The category all is the union of these values.
NB: Order must match _S_facet_categories definition in locale.cc
Definition at line 103 of file locale_classes.h.
const category std::locale::messages [static] |
Category values.
The standard category values are none, ctype, numeric, collate, time, monetary, and messages. They form a bitmask that supports union and intersection. The category all is the union of these values.
NB: Order must match _S_facet_categories definition in locale.cc
Definition at line 108 of file locale_classes.h.
const category std::locale::monetary [static] |
Category values.
The standard category values are none, ctype, numeric, collate, time, monetary, and messages. They form a bitmask that supports union and intersection. The category all is the union of these values.
NB: Order must match _S_facet_categories definition in locale.cc
Definition at line 107 of file locale_classes.h.
const category std::locale::none [static] |
Category values.
The standard category values are none, ctype, numeric, collate, time, monetary, and messages. They form a bitmask that supports union and intersection. The category all is the union of these values.
NB: Order must match _S_facet_categories definition in locale.cc
Definition at line 102 of file locale_classes.h.
const category std::locale::numeric [static] |
Category values.
The standard category values are none, ctype, numeric, collate, time, monetary, and messages. They form a bitmask that supports union and intersection. The category all is the union of these values.
NB: Order must match _S_facet_categories definition in locale.cc
Definition at line 104 of file locale_classes.h.
const category std::locale::time [static] |
Category values.
The standard category values are none, ctype, numeric, collate, time, monetary, and messages. They form a bitmask that supports union and intersection. The category all is the union of these values.
NB: Order must match _S_facet_categories definition in locale.cc
Definition at line 106 of file locale_classes.h.