#include <locale_classes.h>
Public Types | |
typedef int | category |
Definition of locale::category. | |
Public Member Functions | |
locale () throw () | |
Default constructor. | |
locale (const locale &__other) throw () | |
Copy constructor. | |
locale (const char *s) | |
Named locale constructor. | |
locale (const locale &__base, const char *s, category cat) | |
Construct locale with facets from another locale. | |
locale (const locale &__base, const locale &add, category cat) | |
Construct locale with facets from another locale. | |
template<typename Facet> | |
locale (const locale &__other, Facet *__f) | |
Construct locale with another facet. | |
~locale () throw () | |
Locale destructor. | |
const locale & | operator= (const locale &__other) throw () |
Assignment operator. | |
template<typename Facet> | |
locale | combine (const locale &__other) const |
Construct locale with another facet. | |
string | name () const |
Return locale name. | |
bool | operator== (const locale &__other) const throw () |
Locale equality. | |
bool | operator!= (const locale &__other) const throw () |
Locale inequality. | |
template<typename Char, typename Traits, typename Alloc> | |
bool | operator() (const basic_string< Char, Traits, Alloc > &s1, const basic_string< Char, Traits, Alloc > &s2) const |
Compare two strings according to collate. | |
Static Public Member Functions | |
static locale | global (const locale &) |
Set global locale. | |
static const locale & | classic () |
Return reference to the "C" locale. | |
Static Public Attributes | |
static const category | none |
Category values. | |
static const category | ctype |
Category values. | |
static const category | numeric |
Category values. | |
static const category | collate |
Category values. | |
static const category | time |
Category values. | |
static const category | monetary |
Category values. | |
static const category | messages |
Category values. | |
static const category | all |
Category values. | |
Friends | |
template<typename Facet> | |
bool | has_facet (const locale &) throw () |
Test for the presence of a facet. | |
template<typename Facet> | |
const Facet & | use_facet (const locale &) |
Return a facet. | |
Classes | |
class | facet |
Localization functionality base class. More... | |
class | id |
Facet ID class. More... |
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 67 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. |
Definition at line 38 of file localename.cc.
References std::basic_string< CharT, Traits, Alloc >::c_str(), std::basic_string< CharT, Traits, Alloc >::end(), and std::basic_string< CharT, Traits, Alloc >::erase().
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. |
Definition at line 150 of file localename.cc.
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. |
Definition at line 160 of file localename.cc.
std::locale::locale | ( | const locale & | __other, | |
Facet * | __f | |||
) | [inline] |
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 46 of file locale_facets.tcc.
References locale().
string std::locale::name | ( | ) | const |
bool std::locale::operator== | ( | const locale & | __other | ) | const throw () |
Locale equality.
other | The locale to compare against. |
Definition at line 72 of file locale.cc.
Referenced by operator!=().
bool std::locale::operator!= | ( | const locale & | __other | ) | const throw () [inline] |
Locale inequality.
other | The locale to compare against. |
Definition at line 241 of file locale_classes.h.
References 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 63 of file locale_facets.tcc.
References std::basic_string< CharT, Traits, Alloc >::data(), and std::basic_string< CharT, Traits, Alloc >::length().
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(LCALL, loc.name()).
Definition at line 109 of file locale_init.cc.
References std::basic_string< CharT, Traits, Alloc >::c_str(), locale(), and name().
const locale & std::locale::classic | ( | ) | [static] |
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. |
Definition at line 107 of file locale_facets.tcc.
const locale::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.
Definition at line 105 of file locale_classes.h.
const locale::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.
Definition at line 106 of file locale_classes.h.
const locale::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.
Definition at line 107 of file locale_classes.h.
const locale::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.
Definition at line 108 of file locale_classes.h.
const locale::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.
Definition at line 109 of file locale_classes.h.
const locale::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.
Definition at line 110 of file locale_classes.h.
const locale::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.
Definition at line 111 of file locale_classes.h.
const locale::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.
Definition at line 112 of file locale_classes.h.