std::locale - Container class for localization functionality.
Contents
Constructor & Destructor Documentation
std::locale::locale()
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(constlocale&__other)
Copy constructor. Constructs a copy of other.
Parameters__other The locale to copy.
std::locale::locale(constchar*__s)[explicit]
Named locale constructor. Constructs a copy of the named C library locale.
Parameters__s Name of the locale to construct.
Exceptionsstd::runtime_error if __s is null or an undefined locale.
std::locale::locale(constlocale&__base,constchar*__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.
Parameters__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.
Exceptionsstd::runtime_error if __s is null or an undefined locale.
std::locale::locale(conststd::string&__s)[inline],[explicit]
Named locale constructor. Constructs a copy of the named C library locale.
Parameters__s Name of the locale to construct.
Exceptionsstd::runtime_error if __s is an undefined locale.
std::locale::locale(constlocale&__base,conststd::string&__s,category__cat)[inline]
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.
Parameters__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.
Exceptionsstd::runtime_error if __s is an undefined locale.
std::locale::locale(constlocale&__base,constlocale&__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.
Parameters__base The locale to copy.
__add The locale to use facets from.
__cat Set of categories defining the facets to use from add.
template<typename_Facet>std::locale::locale(constlocale&__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.
Parameters__other The locale to copy.
__f The facet to add in.
std::locale::~locale()
Locale destructor.
Detailed Description
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.
Member Data Documentation
constcategorystd::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
constcategorystd::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
constcategorystd::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
constcategorystd::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
constcategorystd::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
constcategorystd::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
constcategorystd::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
constcategorystd::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
Member Function Documentation
staticconstlocale&std::locale::classic()[static]
Return reference to the C locale.
template<typename_Facet>localestd::locale::combine(constlocale&__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.
TemplateParameters_Facet The facet type to copy from other
Parameters__other The locale to copy from.
Returns
Newly constructed locale.
Exceptionsstd::runtime_error if __other has no facet of type _Facet.
References locale().
staticlocalestd::locale::global(constlocale&__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()).
Parameters__loc The new locale to make global.
Returns
Copy of the old global locale.
stringstd::locale::name()const
Return locale name.
Returns
Locale name or '*' if unnamed.
template<typename_Char,typename_Traits,typename_Alloc>boolstd::locale::operator()(constbasic_string<_Char,_Traits,_Alloc>&__s1,constbasic_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);
Parameters__s1 First string to compare.
__s2 Second string to compare.
Returns
True if collate<_Char> facet compares __s1 < __s2, else false.
constlocale&std::locale::operator=(constlocale&__other)
Assignment operator. Set this locale to be a copy of other.
Parameters__other The locale to copy.
Returns
A reference to this locale.
boolstd::locale::operator==(constlocale&__other)const
Locale equality.
Parameters__other The locale to compare against.
Returns
True if other and this refer to the same locale instance, are copies, or have the same name. False
otherwise.
References operator==().
Referenced by operator==().
Member Typedef Documentation
typedefintstd::locale::category
Definition of locale::category.
Name
std::locale - Container class for localization functionality.
Synopsis
#include <locale>
Classes
class facet
Localization functionality base class.
class id
Facet ID class.
PublicTypestypedef int category
Definition of locale::category.
PublicMemberFunctionslocale () throw ()
Default 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.
locale (const locale &__base, const std::string &__s, category__cat)
Construct locale with facets from another locale.
locale (const locale &__other) throw ()
Copy constructor.
template<typename_Facet > locale (const locale &__other, _Facet *__f)
Construct locale with another facet.
locale (const std::string &__s)
Named locale constructor.
~locale () throw ()
Locale destructor.
template<typename_Facet > localecombine (const locale &__other) const
Construct locale with another facet.
stringname () const
Return locale name.
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.
template<typename _CharT , typename _Traits , typename _Alloc > bool operator() (const basic_string<
_CharT, _Traits, _Alloc > &__s1, const basic_string< _CharT, _Traits, _Alloc > &__s2) const
const locale & operator= (const locale &__other) throw ()
Assignment operator.
bool operator== (const locale &__other) const throw ()
Locale equality.
StaticPublicMemberFunctionsstatic const locale & classic ()
Return reference to the C locale.
staticlocaleglobal (const locale &__loc)
Set global locale.
StaticPublicAttributesstatic const categorynone
Category values.
static const categoryctype
Category values.
static const categorynumeric
Category values.
static const categorycollate
Category values.
static const categorytime
Category values.
static const categorymonetary
Category values.
static const categorymessages
Category values.
static const categoryall
Category values.
Friends
template<typename_Facet > const _Facet * __try_use_facet (const locale &) noexcept
template<typename_Cache > struct__use_cacheclass_Implclassfacet
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.
