libstdc++
|
Container class for localization functionality.
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 64 of file locale_classes.h.
typedef int std::locale::category |
Definition of locale::category.
Definition at line 69 of file locale_classes.h.
std::locale::locale | ( | ) | throw () |
Default constructor.
Constructs a copy of the global locale. If no locale has been explicitly set, this is the C locale.
Referenced by combine().
std::locale::locale | ( | const locale & | __other | ) | throw () |
Copy constructor.
Constructs a copy of other.
__other | The locale to copy. |
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. |
std::locale::locale | ( | const locale & | __base, |
const char * | __s, | ||
category | __cat | ||
) |
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 & | __base, |
const locale & | __add, | ||
category | __cat | ||
) |
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 add. If base and add are named, this locale instance will also be named.
__base | The locale to copy. |
__add | The locale to use facets from. |
__cat | Set of categories defining the facets to use from add. |
std::locale::locale | ( | const locale & | __other, |
_Facet * | __f | ||
) |
Construct locale with another facet.
Constructs a copy of the locale __other. The facet __f is added to __other, replacing an existing facet of type Facet if there is one. If __f is null, this locale is a copy of __other.
__other | The locale to copy. |
__f | The facet to add in. |
Definition at line 45 of file locale_classes.tcc.
std::locale::~locale | ( | ) | throw () |
Locale destructor.
static const locale& std::locale::classic | ( | ) | [static] |
Return reference to the C locale.
locale std::locale::combine | ( | const locale & | __other | ) | const |
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.
_Facet | The facet type to copy from other |
__other | The locale to copy from. |
std::runtime_error | if __other has no facet of type _Facet. |
Definition at line 63 of file locale_classes.tcc.
References locale().
static locale std::locale::global | ( | const locale & | __loc | ) | [static] |
Set global locale.
This function sets the global locale to the argument and returns a copy of the previous global locale. If the argument has a name, it will also call std::setlocale(LC_ALL, loc.name()).
__loc | The new locale to make global. |
string std::locale::name | ( | ) | const |
Return locale name.
bool std::locale::operator!= | ( | const locale & | __other | ) | const throw () [inline] |
Locale inequality.
__other | The locale to compare against. |
Definition at line 237 of file locale_classes.h.
References operator==().
bool std::locale::operator() | ( | const basic_string< _Char, _Traits, _Alloc > & | __s1, |
const basic_string< _Char, _Traits, _Alloc > & | __s2 | ||
) | const |
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. |
Assignment operator.
Set this locale to be a copy of other.
__other | The locale to copy. |
bool std::locale::operator== | ( | const locale & | __other | ) | const throw () |
Locale equality.
__other | The locale to compare against. |
Referenced by operator!=().
Test for the presence of a facet.
has_facet tests the locale argument for the presence of the facet type provided as the template parameter. Facets derived from the facet parameter will also return true.
_Facet | The facet type to test the presence of. |
__loc | The locale to test. |
__loc
contains a facet of type _Facet, else false. Definition at line 103 of file locale_classes.tcc.
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.
_Facet | The facet type to access. |
__loc | The locale to use. |
std::bad_cast | if __loc doesn't contain a facet of type _Facet. |
Definition at line 130 of file locale_classes.tcc.
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 107 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 103 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 101 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 106 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 105 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 100 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 102 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 104 of file locale_classes.h.