std::locale(3)

NAME
std::locale -

SYNOPSIS

Detailed Description

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.

  Public Types
typedef int category

  Public Member Functions
template<typename _Facet> locale combine (const locale &__other) const
template<typename _Facet> locale (const locale &__other, _Facet *__f)
locale (const locale &__base, const locale &__add, category __cat)
locale (const locale &__base, const char *__s, category __cat)
locale (const char *__s)
locale (const locale &__other) throw ()
locale () throw ()
string name () const
bool operator!= (const locale &__other) const throw ()
template<typename _Char, typename _Traits, typename _Alloc> bool operator() (const basic_string< _Char, _Traits, _Alloc > &__s1, const basic_string< _Char, _Traits, _Alloc > &__s2) const
const locale & operator= (const locale &__other) throw ()
bool operator== (const locale &__other) const throw ()
~locale () throw ()

  Static Public Member Functions
static const locale & classic ()
static locale global (const locale &)

  Static Public Attributes

static const category all
static const category collate
static const category ctype
static const category messages
static const category monetary
static const category none
static const category numeric
static const category time

  Friends
struct __use_cache
class _Impl
class facet
template<typename _Facet> bool has_facet (const locale &) throw ()
template<typename _Facet> const _Facet & use_facet (const locale &)

  Classes
class _Impl
class facet
Localization functionality base class.
class id
Facet ID class.

Member Typedef Documentation

  typedef int category

Definition of locale::category.

Definition at line 72 of file locale_classes.h.

Constructor & Destructor Documentation

  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 locale::combine().

  locale (const locale & __other) throw ()

Copy constructor.

Constructs a copy of other.

Parameters:
    other The locale to copy.

  locale (const char * __s) [explicit]

Named locale constructor.

Constructs a copy of the named C library locale.

Parameters:
    s Name of the locale to construct.

Exceptions:
    std::runtime_error if s is null or an undefined 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.

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.

Exceptions:
    std::runtime_error if s is null or an undefined 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.

Parameters:
    base The locale to copy.
    add The locale to use facets from.
    cat Set of categories defining the facets to use from add.

  locale (const locale & __other, _Facet * __f)

Construct locale with another facet.

Constructs a copy of the locale other. The facet is added to , replacing an existing facet of type Facet if there is one. If is null, this locale is a copy of other.

Parameters:
    other The locale to copy.
    f The facet to add in.

Definition at line 566 of file locale_classes.h.

References locale::_Impl, locale::_M_impl, locale::_Impl::_M_install_facet(), locale::_Impl::_M_names, and locale::_Impl::_M_remove_reference().

  ~locale () throw ()

Locale destructor.

Member Function Documentation

  static const locale& classic () [static]

Return reference to the 'C' locale.

  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.

Parameters:
    Facet The facet type to copy from other
    other The locale to copy from.

Returns:
    Newly constructed locale.

Exceptions:
    std::runtime_error if other has no facet of type Facet.

Definition at line 49 of file locale_facets.tcc.

References locale::_Impl, locale::_M_impl, locale::_Impl::_M_remove_reference(), locale::_Impl::_M_replace_facet(), and locale::locale().

  static locale global (const locale &) [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:
    locale The new locale to make global.

Returns:
    Copy of the old global locale.

  string name () const

Return locale name.

Returns:
    Locale name or '*' if unnamed.

  bool operator!= (const locale & __other) const throw () [inline]

Locale inequality.

Parameters:
    other The locale to compare against.

Returns:
    ! (*this == other)

Definition at line 241 of file locale_classes.h.

References locale::operator==().

  bool 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);

Parameters:
    s1 First string to compare.
    s2 Second string to compare.

Returns:
    True if collate<Char> facet compares s1 < s2, else false.

Definition at line 66 of file locale_facets.tcc.

References basic_string::data(), and basic_string::length().

  const locale& operator= (const locale & __other) throw ()

Assignment operator.

Set this locale to be a copy of other.

Parameters:
    other The locale to copy.

Returns:
    A reference to this locale.

  bool operator== (const locale & __other) const throw ()

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.

Referenced by locale::operator!=().

Friends And Related Function Documentation

  bool has_facet (const locale & __loc) throw () [friend]

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.

Parameters:
    Facet The facet type to test the presence of.
    locale The locale to test.

Returns:
    true if locale contains a facet of type Facet, else false.

Definition at line 88 of file locale_facets.tcc.

  const _Facet& use_facet (const locale & __loc) [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.

Parameters:
    Facet The facet type to access.
    locale The locale to use.

Returns:
    Reference to facet of type Facet.

Exceptions:
    std::bad_cast if locale doesn't contain a facet of type Facet.

Definition at line 110 of file locale_facets.tcc.

Member Data Documentation

  const category 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.

Author

Generated automatically by Doxygen for libstdc++ from the source code.