<locale>


codecvt · codecvt_base · codecvt_byname · collate · collate_byname · ctype · ctype<char> · ctype_base · ctype_byname · has_facet · locale · messages · messages_base · messages_byname · money_base · money_get · money_put · moneypunct · moneypunct_byname · num_get · num_put · numpunct · numpunct_byname · time_base · time_get · time_get_byname · time_put · time_put_byname · use_facet · wbuffer_convert · wstring_convert

isalnum · isalpha · isblank · iscntrl · isdigit · isgraph · islower · isprint · ispunct · isspace · isupper · isxdigit · tolower · toupper


Include the standard header <locale> to define a host of template classes and functions that encapsulate and manipulate locales.

namespace std {
class locale;
class ctype_base;
template<class Elem>
    class ctype;
template<>
    class ctype<char>;
template<class Elem>
    class ctype_byname;
class codecvt_base;
template<class Elem, class Byte, class Statype>
    class codecvt;
template<class Elem, class Byte, class Statype>
    class codecvt_byname;
template<class Elem, class InIt>
    class num_get;
template<class Elem, class OutIt>
    class num_put;
template<class Elem>
    class numpunct;
template<class Elem>
    class numpunct_byname;
template<class Elem>
    class collate;
template<class Elem>
    class collate_byname;
class time_base;
template<class Elem, class InIt>
    class time_get;
template<class Elem, class InIt>
    class time_get_byname;
template<class Elem, class OutIt>
    class time_put;
template<class Elem, class OutIt>
    class time_put_byname;
class money_base;
template<class Elem, bool Intl, class InIt>
    class money_get;
template<class Elem, bool Intl, class OutIt>
    class money_put;
template<class Elem, bool Intl>
    class moneypunct;
template<class Elem, bool Intl>
    class moneypunct_byname;
class messages_base;
template<class Elem>
    class messages;
template<class Elem>
    class messages_byname;

template<class Codecvt,
    class Elem = wchar_t,
    class Tr = char_traits<Elem> >
    class wbuffer_convert;
template<class Codecvt,
    class Elem = wchar_t,
    class Walloc = allocator<Elem>,
    class Balloc = allocator<char> >
    class wstring_convert;

        // TEMPLATE FUNCTIONS
template<class Facet>
    bool has_facet(const locale& loc);
template<class Facet>
    const Facet& use_facet(const locale& loc);
template<class Elem>
    bool isblank(Elem ch, const locale& loc) const;
template<class Elem>
    bool isspace(Elem ch, const locale& loc) const;
template<class Elem>
    bool isprint(Elem ch, const locale& loc) const;
template<class Elem>
    bool iscntrl(Elem ch, const locale& loc) const;
template<class Elem>
    bool isupper(Elem ch, const locale& loc) const;
template<class Elem>
    bool islower(Elem ch, const locale& loc) const;
template<class Elem>
    bool isalpha(Elem ch, const locale& loc) const;
template<class Elem>
    bool isdigit(Elem ch, const locale& loc) const;
template<class Elem>
    bool ispunct(Elem ch, const locale& loc) const;
template<class Elem>
    bool isxdigit(Elem ch, const locale& loc) const;
template<class Elem>
    bool isalnum(Elem ch, const locale& loc) const;
template<class Elem>
    bool isgraph(Elem ch, const locale& loc) const;
template<class Elem>
    Elem toupper(Elem ch, const locale& loc) const;
template<class Elem>
    Elem tolower(Elem ch, const locale& loc) const;
}  // namespace std

codecvt

template<class Elem, class Byte, class Statype>
    class codecvt
        : public locale::facet, codecvt_base {
public:
    typedef Elem intern_type;
    typedef Byte extern_type;
    typedef Statype state_type;

    explicit codecvt(size_t refs = 0);

    result in(Statype& state,
        const Byte *first1, const Byte *last1,
            const Byte *next1,
        Elem *first2, Elem *last2, Elem *next2);
    result out(Statype& state,
        const Elem *first1, const Elem *last1,
            const Elem *next1,
        Byte *first2, Byte *last2, Byte *next2);
    result unshift(Statype& state,
        Byte *first2, Byte *last2, Byte *next2);

    bool always_noconv() const throw();
    int max_length() const throw();
    int length(Statype& state,
        const Byte *first1, const Byte *last1,
            size_t _N2) const throw();
    int encoding() const throw();

    static locale::id id;

protected:
    ~codecvt();

    virtual result do_in(Statype& state,
        const Byte *first1, const Byte *last1,
            const Byte *next1,
        Elem *first2, Elem *last2, Elem *next2);
    virtual result do_out(Statype& state,
        const Elem *first1, const Elem *last1,
            const Elem *next1,
        Byte *first2, Byte *last2, Byte *next2);
    virtual result do_unshift(Statype& state,
        Byte *first2, Byte *last2, Byte *next2);

    virtual bool do_always_noconv() const throw();
    virtual int do_max_length() const throw();
    virtual int do_encoding() const throw();
    virtual int do_length(Statype& state,
        const Byte *first1, const Byte *last1,
            size_t len2) const throw();
    };

The template class describes an object that can serve as a locale facet, to control conversions between a sequence of values of type Elem and a sequence of values of type Byte. The class Statype characterizes the transformation -- and an object of class Statype stores any necessary state information during a conversion.

As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id.

The template versions of do_in and do_out always return codecvt_base::noconv. The Standard C++ library defines several explicit specializations, however, that are more useful:

template<>
    codecvt<wchar_t, char, mbstate_t>

which converts between wchar_t and char sequences.

template<>
    codecvt<char16_t, char, mbstate_t> [added with C++11]

which converts between char16_t sequences encoded as UTF-16 and char sequences encoded as UTF-8.

template<>
    codecvt<char32_t, char, mbstate_t> [added with C++11]

which converts between char32_t sequences encoded as UTF-32 (UCS-4) and char sequences encoded as UTF-8.

codecvt::always_noconv

bool always_noconv() const throw();

The member function returns do_always_noconv().

codecvt::codecvt

explicit codecvt(size_t refs = 0);

The constructor initializes its locale::facet base object with locale::facet(refs).

codecvt::do_always_noconv

virtual bool do_always_noconv() const throw();

The protected virtual member function returns true only if every call to do_in or do_out returns noconv. The template version always returns true.

codecvt::do_encoding

virtual int do_encoding() const throw();

The protected virtual member function returns:

codecvt::do_in

virtual result do_in(Statype state&,
    const Byte *first1, const Byte *last1, const Byte *next1,
    Elem *first2, Elem *last2, Elem *next2);

The protected virtual member function endeavors to convert the source sequence at [first1, last1) to a destination sequence that it stores within [first2, last2). It always stores in next1 a pointer to the first unconverted element in the source sequence, and it always stores in next2 a pointer to the first unaltered element in the destination sequence.

state must represent the initial conversion state at the beginning of a new source sequence. The function alters its stored value, as needed, to reflect the current state of a successful conversion. Its stored value is otherwise unspecified.

The function returns:

The template version always returns noconv.

codecvt::do_length

virtual int do_length(Statype state&,
    const Byte *first1, const Byte *last1,
        size_t len2) const throw();

The protected virtual member function effectively calls do_in(mystate, first1, last1, next1, buf, buf + len2, next2) for mystate a copy of state, some buffer buf, and pointers next1 and next2. It then returns next2 - buf. (Thus, it counts the maximum number of conversions, not greater than len2, defined by the source sequence at [first1, last1).)

The template version always returns the lesser of last1 - first1 and len2.

codecvt::do_max_length

virtual int do_max_length() const throw();

The protected virtual member function returns the largest permissible value that can be returned by do_length(first1, last1, 1), for arbitrary valid values of first1 and last1. (Thus, it is roughly analogous to the macro MB_CUR_MAX, at least when Byte is type char.)

The template version always returns 1.

codecvt::do_out

virtual result do_out(Statype state&,
    const Elem *first1, const Elem *last1,
        const Elem *next1,
    Byte *first2, Byte *last2, Byte *next2);

The protected virtual member function endeavors to convert the source sequence at [first1, last1) to a destination sequence that it stores within [first2, last2). It always stores in next1 a pointer to the first unconverted element in the source sequence, and it always stores in next2 a pointer to the first unaltered element in the destination sequence.

state must represent the initial conversion state at the beginning of a new source sequence. The function alters its stored value, as needed, to reflect the current state of a successful conversion. Its stored value is otherwise unspecified.

The function returns:

The template version always returns noconv.

codecvt::do_unshift

virtual result do_unshift(Statype state&,
    Byte *first2, Byte *last2, Byte *next2);

The protected virtual member function endeavors to convert the source element Elem(0) to a destination sequence that it stores within [first2, last2), except for the terminating element Byte(0). It always stores in next2 a pointer to the first unaltered element in the destination sequence.

state must represent the initial conversion state at the beginning of a new source sequence. The function alters its stored value, as needed, to reflect the current state of a successful conversion. Typically, converting the source element Elem(0) leaves the current state in the initial conversion state.

The function returns:

The template version always returns noconv.

codecvt::extern_type

typedef Byte extern_type;

The type is a synonym for the template parameter Byte.

codecvt::in

result in(Statype state&,
    const Byte *first1, const Byte *last1, const Byte *next1,
    Elem *first2, Elem *last2, Elem *next2);

The member function returns do_in(state, first1, last1, next1, first2, last2, next2).

codecvt::intern_type

typedef Elem intern_type;

The type is a synonym for the template parameter Elem.

codecvt::length

int length(Statype state&,
    const Byte *first1, const Byte *last1,
        size_t len2) const throw();

The member function returns do_length(first1, last1, len2).

codecvt::encoding

int encoding() const throw();

The member function returns do_encoding().

codecvt::max_length

int max_length() const throw();

The member function returns do_max_length().

codecvt::out

result out(Statype state&,
    const Elem *first1, const Elem *last1,
        const Elem *next1,
    Byte *first2, Byte *last2, Byte *next2);

The member function returns do_out(state, first1, last1, next1, first2, last2, next2).

codecvt::state_type

typedef Statype state_type;

The type is a synonym for the template parameter Statype.

codecvt::unshift

result unshift(Statype state&,
    Byte *first2, Byte *last2, Byte *next2);

The member function returns do_unshift(state, first2, last2, next2).

codecvt_base

class codecvt_base {
public:
    enum result {ok, partial, error, noconv};
    };

The class describes an enumeration common to all specializations of template class codecvt. The enumeration result describes the possible return values from do_in or do_out:

codecvt_byname

template<class Elem, class Byte, class Statype>
    class codecvt_byname
        : public codecvt<Elem, Byte, Statype> {
public:
    explicit codecvt_byname(const char *locname,
        size_t refs = 0);
    explicit codecvt_byname(const string& locname,
        size_t refs = 0); [added with C++11]

protected:
    ~codecvt_byname();
    };

The template class describes an object that can serve as a locale facet of type codecvt<Elem, Byte, Statype>. Its behavior is determined by the named locale locname. Each constructor initializes its base object with codecvt<Elem, Byte, Statype>(refs).

collate

template<class Elem>
    class collate
        : public locale::facet {
public:
    typedef Elem char_type;
    typedef basic_string<Elem> string_type;

    explicit collate(size_t refs = 0);

    int compare(const Elem *first1, const Elem *last1,
        const Elem *first2, const Elem *last2) const;
    string_type transform(const Elem *first,
        const Elem *last) const;
    long hash(const Elem *first, const Elem *last) const;
    static locale::id id;

protected:
    ~collate();

    virtual int
        do_compare(const Elem *first1, const Elem *last1,
            const Elem *first2, const Elem *last2) const;
    virtual string_type do_transform(const Elem *first,
        const Elem *last) const;
    virtual long do_hash(const Elem *first,
        const Elem *last) const;
    };

The template class describes an object that can serve as a locale facet, to control comparisons of sequences of type Elem.

As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id.

collate::char_type

typedef Elem char_type;

The type is a synonym for the template parameter Elem.

collate::collate

explicit collate(size_t refs = 0);

The constructor initializes its base object with locale::facet(refs).

collate::compare

int compare(const Elem *first1, const Elem *last1,
    const Elem *first2, const Elem *last2) const;

The member function returns do_compare(first1, last1, first2, last2).

collate::do_compare

virtual int do_compare(const Elem *first1, const Elem *last1,
    const Elem *first2, const Elem *last2) const;

The protected virtual member function compares the sequence at [first1, last1) with the sequence at [first2, last2). It compares values by applying operator< between pairs of corresponding elements of type Elem. The first sequence compares less if it has the smaller element in the earliest unequal pair in the sequences, or if no unequal pairs exist but the first sequence is shorter.

If the first sequence compares less than the second sequence, the function returns -1. If the second sequence compares less, the function returns +1. Otherwise, the function returns zero.

collate::do_hash

virtual long do_hash(const Elem *first,
    const Elem *last) const;

The protected virtual member function returns an integer derived from the values of the elements in the sequence [first, last). Such a hash value can be useful, for example, in distributing sequences pseudo randomly across an array of lists.

collate::do_transform

virtual string_type do_transform(const Elem *first,
    const Elem *last) const;

The protected virtual member function returns an object of class string_type whose controlled sequence is a copy of the sequence [first, last). If a class derived from collate<Elem> overrides do_compare, it should also override do_transform to match. Put simply, two transformed strings should yield the same result, when passed to collate::compare, that you would get from passing the untransformed strings to compare in the derived class.

collate::hash

long hash(const Elem *first, const Elem *last) const;

The member function returns do_hash(first, last).

collate::string_type

typedef basic_string<Elem> string_type;

The type describes a specialization of template class basic_string whose objects can store copies of the source sequence.

collate::transform

string_type transform(const Elem *first,
    const Elem *last) const;

The member function returns do_transform(first, last).

collate_byname

template<class Elem>
    class collate_byname
        : public collate<Elem> {
public:
    explicit collate_byname(const char *locname,
        size_t refs = 0);
    explicit collate_byname(const string& locname,
        size_t refs = 0); [added with C++11]

protected:
    ~collate_byname();
    };

The template class describes an object that can serve as a locale facet of type collate<Elem>. Its behavior is determined by the named locale locname. Each constructor initializes its base object with collate<Elem>(refs).

ctype


char_type · ctype · do_is · do_narrow · do_scan_is · do_scan_not · do_tolower · do_toupper · do_widen · is · narrow · scan_is · scan_not · tolower · toupper · widen


template<class Elem>
    class ctype
        : public locale::facet, public ctype_base {
public:
    typedef Elem char_type;

    explicit ctype(size_t refs = 0);

    bool is(mask maskval, Elem ch) const;
    const Elem *is(const Elem *first, const Elem *last,
        mask *dest) const;
    const Elem *scan_is(mask maskval, const Elem *first,
        const Elem *last) const;
    const Elem *scan_not(mask maskval, const Elem *first,
        const Elem *last) const;

    Elem toupper(Elem ch) const;
    const Elem *toupper(Elem *first, Elem *last) const;
    Elem tolower(Elem ch) const;
    const Elem *tolower(Elem *first, Elem *last) const;

    Elem widen(char byte) const;
    const char *widen(char *first, char *last,
        Elem *dest) const;
    char narrow(Elem ch, char dflt) const;
    const Elem *narrow(const Elem *first, const Elem *last,
        char dflt, char *dest) const;

    static locale::id id;

protected:
    ~ctype();

    virtual bool do_is(mask maskval, Elem ch) const;
    virtual const Elem *do_is(const Elem *first, const Elem *last,
        mask *dest) const;
    virtual const Elem *do_scan_is(mask maskval, const Elem *first,
        const Elem *last) const;
    virtual const Elem *do_scan_not(mask maskval, const Elem *first,
        const Elem *last) const;

    virtual Elem do_toupper(Elem ch) const;
    virtual const Elem *do_toupper(Elem *first, Elem *last) const;
    virtual Elem do_tolower(Elem ch) const;
    virtual const Elem *do_tolower(Elem *first, Elem *last) const;

    virtual Elem do_widen(char byte) const;
    virtual const char *do_widen(char *first, char *last,
        Elem *dest) const;
    virtual char do_narrow(Elem ch, char dflt) const;
    virtual const Elem *do_narrow(const Elem *first,
        const Elem *last, char dflt, char *dest) const;
    };

The template class describes an object that can serve as a locale facet, to characterize various properties of a ``character'' (element) of type Elem. Such a facet also converts between sequences of Elem elements and sequences of char.

As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id.

The Standard C++ library defines two explicit specializations of this template class:

In this implementation, other specializations of template class ctype<Elem>:

All other operations are performed on char values the same as for the explicit specialization ctype<char>.

ctype::char_type

typedef Elem char_type;

The type is a synonym for the template parameter Elem.

ctype::ctype

explicit ctype(size_t refs = 0);

The constructor initializes its locale::facet base object with locale::facet(refs).

ctype::do_is

virtual bool do_is(mask maskval, Elem ch) const;
virtual const Elem *do_is(const Elem *first, const Elem *last,
    mask *dest) const;

The first protected member template function returns true if MASK(ch) & maskval is nonzero, where MASK(ch) designates the mapping between an element value ch and its classification mask, of type mask. The name MASK is purely symbolic here; it is not defined by the template class. For an object of class ctype<char>, the mapping is tab[(unsigned char)(char)ch], where tab is the stored pointer to the ctype mask table.

The second protected member template function stores in dest[I] the value MASK(first[I]) & maskval, where I ranges over the interval [0, last - first).

ctype::do_narrow

virtual char do_narrow(Elem ch, char dflt) const;
virtual const Elem *do_narrow(const Elem *first, const Elem *last,
    char dflt, char *dest) const;

The first protected member template function returns (char)ch, or dflt if that expression is undefined.

The second protected member template function stores in dest[I] the value do_narrow(first[I], dflt), for I in the interval [0, last - first).

ctype::do_scan_is

virtual const Elem *do_scan_is(mask maskval, const Elem *first,
    const Elem *last) const;

The protected member function returns the smallest pointer ptr in the range [first, last) for which do_is(maskval, *ptr) is true. If no such value exists, the function returns last.

ctype::do_scan_not

virtual const Elem *do_scan_not(mask maskval, const Elem *first,
    const Elem *last) const;

The protected member function returns the smallest pointer ptr in the range [first, last) for which do_is(maskval, *ptr) is false. If no such value exists, the function returns last.

ctype::do_tolower

virtual Elem do_tolower(Elem ch) const;
virtual const Elem *do_tolower(Elem *first, Elem *last) const;

The first protected member template function returns the lowercase character corresponding to ch, if such a character exists. Otherwise, it returns ch.

The second protected member template function replaces each element first[I], for I in the interval [0, last - first), with do_tolower(first[I]).

ctype::do_toupper

virtual Elem do_toupper(Elem ch) const;
virtual const Elem *do_toupper(Elem *first, Elem *last) const;

The first protected member template function returns the uppercase character corresponding to ch, if such a character exists. Otherwise, it returns ch.

The second protected member template function replaces each element first[I], for I in the interval [0, last - first), with do_toupper(first[I]).

ctype::do_widen

virtual Elem do_widen(char byte) const;
virtual const char *do_widen(char *first, char *last,
    Elem *dest) const;

The first protected member template function returns Elem(byte).

The second protected member template function stores in dest[I] the value do_widen(first[I]), for I in the interval [0, last - first).

ctype::is

bool is(mask maskval, Elem ch) const;
const Elem *is(const Elem *first, const Elem *last,
    mask *dest) const;

The first member function returns do_is(maskval, ch). The second member function returns do_is(first, last, dest).

ctype::narrow

char narrow(Elem ch, char dflt) const;
const Elem *narrow(const Elem *first, const Elem *last,
    char dflt, char *dest) const;

The first member function returns do_narrow(ch, dflt). The second member function returns do_narrow(first, last, dflt, dest).

ctype::scan_is

const Elem *scan_is(mask maskval, const Elem *first,
    const Elem *last) const;

The member function returns do_scan_is(maskval, first, last).

ctype::scan_not

const Elem *scan_not(mask maskval, const Elem *first,
    const Elem *last) const;

The member function returns do_scan_not(maskval, first, last).

ctype::tolower

Elem tolower(Elem ch) const;
const Elem *tolower(Elem *first, Elem *last) const;

The first member function returns do_tolower(ch). The second member function returns do_tolower(first, last).

ctype::toupper

Elem toupper(Elem ch) const;
const Elem *toupper(Elem *first, Elem *last) const;

The first member function returns do_toupper(ch). The second member function returns do_toupper(first, last).

ctype::widen

Elem widen(char byte) const;
const char *widen(char *first, char *last, Elem *dest) const;

The first member function returns do_widen(byte). The second member function returns do_widen(first, last, dest).

ctype<char>

template<>
    class ctype<char>
        : public locale::facet, public ctype_base {
public:
    typedef char char_type;

    explicit ctype(const mask *tab = 0, bool del = false,
        size_t refs = 0);

    bool is(mask maskval, char ch) const;
    const char *is(const char *first, const char *last,
        mask *dest) const;
    const char *scan_is(mask maskval,
        const char *first, const char *last) const;
    const char *scan_not(mask maskval,
        const char *first, const char *last) const;

    char toupper(char ch) const;
    const char *toupper(char *first, char *last) const;
    char tolower(char ch) const;
    const char *tolower(char *first, char *last) const;
    char widen(char byte) const;

    const char *widen(char *first, char *last,
        char *dest) const;
    char narrow(char ch, char dflt) const;
    const char *narrow(const char *first,
        const char *last, char dflt, char *dest) const;

    const mask *table() const throw();
    static const mask *classic_table() const throw();
    static const size_t table_size;

    static locale::id id;

protected:
    ~ctype();
    virtual char do_toupper(char ch) const;
    virtual const char *do_toupper(char *first,
        char *last) const;
    virtual char do_tolower(char ch) const;
    virtual const char *do_tolower(char *first,
        char *last) const;

    virtual char do_widen(char ch) const;
    virtual const char *do_widen(char *first, char *last,
        char *dest) const;
    virtual char do_narrow(char ch, char dflt) const;
    virtual const char *do_narrow(const char *first,
        const char *last, char dflt, char *dest) const;
    };

The class is an explicit specialization of template class ctype for type char. Hence, it describes an object that can serve as a locale facet, to characterize various properties of a ``character'' (element) of type char. The explicit specialization differs from the template class in several ways:

ctype_base

class ctype_base {
public:
    typedef T1 mask;
    static const fmtflags space, print, cntrl,
        upper, lower, digit, punct,
        xdigit, alpha, alnum, graph,
        blank;
    };

The class serves as a base class for facets of template class ctype. It defines the type mask in terms of the bitmask type T1. All of the constant members except alnum and graph are bitmask elements of this type. Each of the constant members characterizes a different way to classify characters, as defined by the functions with similar names declared in the header <ctype.h>. The constants are:

You can charaterize a combination of classifications by ORing these constants. In particular, it is always true that alnum == (alpha | digit) and graph == (alnum | punct).

ctype_byname

template<class Elem>
    class ctype_byname
        : public ctype<Elem> {
public:
    explicit ctype_byname(const char *locname,
        size_t refs = 0);
    explicit ctype_byname(const string& locname,
        size_t refs = 0); [added with C++11]

protected:
    ~ctype_byname();
    };

The template class describes an object that can serve as a locale facet of type ctype<Elem>. Its behavior is determined by the named locale locname. Each constructor initializes its base object with ctype<Elem>(refs) (or the equivalent for base class ctype<char>).

has_facet

template<class Facet>
    bool has_facet(const locale& loc);

The template function returns true if a locale facet of class Facet is listed within the locale object loc.

isalnum

template<class Elem>
    bool isalnum(Elem ch, const locale& loc) const;

The template function returns use_facet< ctype<Elem> >(loc). is(ctype<Elem>:: alnum, ch).

isalpha

template<class Elem>
    bool isalpha(Elem ch, const locale& loc) const;

The template function returns use_facet< ctype<Elem> >(loc). is(ctype<Elem>:: alpha, ch).

isblank

template<class Elem>
    bool isblank(Elem ch, const locale& loc) const;

The template function returns use_facet< ctype<Elem> >(loc). is(ctype<Elem>:: blank, ch).

iscntrl

template<class Elem>
    bool iscntrl(Elem ch, const locale& loc) const;

The template function returns use_facet< ctype<Elem> >(loc). is(ctype<Elem>:: cntrl, ch).

isdigit

template<class Elem>
    bool isdigit(Elem ch, const locale& loc) const;

The template function returns use_facet< ctype<Elem> >(loc). is(ctype<Elem>:: digit, ch).

isgraph

template<class Elem>
    bool isgraph(Elem ch, const locale& loc) const;

The template function returns use_facet< ctype<Elem> >(loc). is(ctype<Elem>:: graph, ch).

islower

template<class Elem>
    bool islower(Elem ch, const locale& loc) const;

The template function returns use_facet< ctype<Elem> >(loc). is(ctype<Elem>:: lower, ch).

isprint

template<class Elem>
    bool isprint(Elem ch, const locale& loc) const;

The template function returns use_facet< ctype<Elem> >(loc). is(ctype<Elem>:: print, ch).

ispunct

template<class Elem>
    bool ispunct(Elem ch, const locale& loc) const;

The template function returns use_facet< ctype<Elem> >(loc). is(ctype<Elem>:: punct, ch).

isspace

template<class Elem>
    bool isspace(Elem ch, const locale& loc) const;

The template function returns use_facet< ctype<Elem> >(loc). is(ctype<Elem>:: space, ch).

isupper

template<class Elem>
    bool isupper(Elem ch, const locale& loc) const;

The template function returns use_facet< ctype<Elem> >(loc). is(ctype<Elem>:: upper, ch).

isxdigit

template<class Elem>
    bool isxdigit(Elem ch, const locale& loc) const;

The template function returns use_facet< ctype<Elem> >(loc). is(ctype<Elem>:: xdigit, ch).

locale


category · classic · combine · facet · global · id · locale · name · operator!= · operator() · operator==


class locale {
public:
    class facet;
    class id;
    typedef int category;
    static const category none, collate, ctype, monetary,
        numeric, time, messages, all;
    locale();
    explicit locale(const char *locname);
    explicit locale(const string& locname); [added with C++11]
    locale(const locale& loc, const locale& other,
        category cat);
    locale(const locale& loc, const char *locname, category cat);
    locale(const locale& loc, const string& locname, category cat); [added with C++11]
    template<class Facet>
        locale(const locale& loc, Facet *fac);
    template<class Facet>
        locale combine(const locale& loc) const;
    template<class Elem, class Tr, class Alloc>
        bool operator()(const basic_string<Elem, Tr, Alloc>& left,
            const basic_string<Elem, Tr, Alloc>& right) const;
    string name() const;
    bool operator==(const locale& right) const;
    bool operator!=(const locale& right) const;
    static locale global(const locale& right);
    static const locale& classic();
    };

The class describes a locale object that encapsulates a locale. It represents culture-specific information as a list of facets. A facet is a pointer to an object of a class derived from class facet that has a public object of the form:

static locale::id id;

You can define an open-ended set of these facets. You can also construct a locale object that designates an arbitrary number of facets.

Predefined groups of these facets represent the locale categories traditionally managed in the Standard C library by the function setlocale.

Category collate (LC_COLLATE) includes the facets:

collate<char>
collate<wchar_t>

Category ctype (LC_CTYPE) includes the facets:

ctype<char>
ctype<wchar_t>
codecvt<char, char, mbstate_t>
codecvt<wchar_t, char, mbstate_t>

Category monetary (LC_MONETARY) includes the facets:

moneypunct<char, false>
moneypunct<wchar_t, false>
moneypunct<char, true>
moneypunct<wchar_t, true>
money_get<char, istreambuf_iterator<char> >
money_get<wchar_t, istreambuf_iterator<wchar_t> >
money_put<char, ostreambuf_iterator<char> >
money_put<wchar_t, ostreambuf_iterator<wchar_t> >

Category numeric (LC_NUMERIC) includes the facets:

num_get<char, istreambuf_iterator<char> >
num_get<wchar_t, istreambuf_iterator<wchar_t> >
num_put<char, ostreambuf_iterator<char> >
num_put<wchar_t, ostreambuf_iterator<wchar_t> >
numpunct<char>
numpunct<wchar_t>

Category time (LC_TIME) includes the facets:

time_get<char, istreambuf_iterator<char> >
time_get<wchar_t, istreambuf_iterator<wchar_t> >
time_put<char, ostreambuf_iterator<char> >
time_put<wchar_t, ostreambuf_iterator<wchar_t> >

Category messages (LC_MESSAGES) includes the facets:

messages<char>
messages<wchar_t>

(The last category is required by Posix, but not the C Standard.)

Some of these predefined facets are used by the iostreams classes, to control the conversion of numeric values to and from text sequences.

Note that in any facet it is unspecified whether one virtual function calls another virtual function.

An object of class locale also stores a locale name as an object of class string. Using an invalid locale name to construct a locale facet or a locale object throws an object of class runtime_error. The stored locale name is "*" if the locale object cannot be certain that a C-style locale corresponds exactly to that represented by the object. Otherwise, you can establish a matching locale within the Standard C library, for the locale object loc, by calling setlocale( LC_ALL, loc.name. c_str()).

In this implementation, you can also call the static member function:

static locale empty();

to construct a locale object that has no facets. It is also a transparent locale -- if the template functions has_facet and use_facet cannot find the requested facet in a transparent locale, they consult first the global locale and then, if that is transparent, the classic locale. Thus, you can write:

cout.imbue(locale::empty());

Subsequent insertions to cout are mediated by the current state of the global locale. You can even write:

locale loc(locale::empty(), locale::classic(),
    locale::numeric);
cout.imbue(loc);

Numeric formatting rules for subsequent insertions to cout remain the same as in the C locale, even as the global locale supplies changing rules for inserting dates and monetary amounts.

locale::category

typedef int category;
static const category none, collate, ctype, monetary,
    numeric, time, messages, all;

The type is a synonym for int so that it can represent any of the C locale categories. It can represent a group of distinct elements of a bitmask type (which is anonymous) local to class locale. The elements are:

In addition, two useful values are:

You can represent an arbitrary group of categories by ORing these constants, as in monetary | time.

locale::classic

static const locale& classic();

The static member function returns a locale object that represents the classic locale, which behaves the same as the C locale within the Standard C library.

locale::combine

template<class Facet>
    locale combine(const locale& loc) const;

The member function returns a locale object that replaces in (or adds to) *this the facet Facet listed in loc.

locale::facet

class facet {
protected:
    explicit facet(size_t refs = 0);
    virtual ~facet();

private:
    facet(const facet&) = delete; [added with C++11]
    void operator=(const facet&) = delete; [added with C++11]
    };

The member class serves as the base class for all locale facets. Note that you can neither copy nor assign an object of class facet. You can construct and destroy objects derived from class locale::facet, but not objects of the base class proper. Typically, you construct an object myfac derived from facet when you construct a locale, as in:

locale loc(locale::classic(), new myfac);

In such cases, the constructor for the base class facet should have a zero refs argument. When the object is no longer needed, it is deleted. Thus, you supply a nonzero refs argument only in those rare cases where you take responsibility for the lifetime of the object.

locale::global

static locale global(const locale& loc);

The static member function stores a copy of loc as the global locale. It also calls setlocale( LC_ALL, loc.name. c_str()), to establishing a matching locale within the Standard C library. The function then returns the previous global locale. At program startup, the global locale is the same as the classic locale.

locale::id

class id {
protected:
    id();

private:
    id(const id&) = delete; [added with C++11]
    void operator=(const id&) = delete; [added with C++11]
    };

The member class describes the static member object required by each unique locale facet. Note that you can neither copy nor assign an object of class id.

locale::locale

locale();
explicit locale(const char *locname);
explicit locale(const srting& locname); [added with C++11]
locale(const locale& loc, const locale& other,
    category cat);
locale(const locale& loc, const char *locname, category cat);
locale(const locale& loc, const string& locname, category cat); [added with C++11]
template<class Facet>
    locale(const locale& loc, Facet *fac);

The first constructor initializes the object to match the global locale. The second and third constructors initialize all the locale categories to have behavior consistent with the locale name locname. The remaining constructors copy loc, with the exceptions noted:

locale(const locale& loc, const locale& other,
    category cat);

replaces from other those facets corresponding to a category C for which C & cat is nonzero.

locale(const locale& loc, const char *locname, category cat);
locale(const locale& loc, const string& locname, category cat); [added with C++11]

replace from locale(locname) those facets corresponding to a category C for which C & cat is nonzero.

template<class Facet>
    locale(const locale& loc, Facet *fac);

replaces in (or adds to) loc the facet fac, if fac is not a null pointer.

If a locale name locname is a null pointer or otherwise invalid, the function throws runtime_error.

locale::name

string name() const;

The member function returns the stored locale name.

locale::operator!=

bool operator!=(const locale& right) const;

The member function returns !(*this == right).

locale::operator()

template<class Elem, class Tr, class Alloc>
    bool operator()(const basic_string<Elem, Tr, Alloc>& left,
        const basic_string<Elem, Tr, Alloc>& right);

The member function effectively executes:

const collate<Elem>& fac = use_fac<collate<Elem> >(*this);
return (fac.compare(left.begin(), left.end(),
    right.begin(), right.end()) < 0);

Thus, you can use a locale object as a function object.

locale::operator==

bool operator==(const locale& right) const;

The member function returns true only if *this and right are copies of the same locale or have the same name (other than "*").

messages

template<class Elem>
    class messages
        : public locale::facet, public messages_base {
public:
    typedef Elem char_type;
    typedef basic_string<Elem> string_type;

    explicit messages(size_t refs = 0);

    catalog open(const string& catname,
        const locale& loc) const;
    string_type get(catalog catval, int set, int message,
        const string_type& dflt) const;
    void close(catalog catval) const;
    static locale::id id;

protected:
    ~messages();

    virtual catalog do_open(const string& catname,
        const locale& loc) const;
    virtual string_type do_get(catalog catval, int set,
        int message, const string_type& dflt) const;
    virtual void do_close(catalog catval) const;
    };

The template class describes an object that can serve as a locale facet, to characterize various properties of a message catalog that can supply messages represented as sequences of elements of type Elem.

As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id.

messages::char_type

typedef Elem char_type;

The type is a synonym for the template parameter Elem.

messages::close

void close(catalog catval) const;

The member function calls do_close(catval);.

messages::do_close

virtual void do_close(catalog catval) const;

The protected member function closes the message catalog catval, which must have been opened by an earlier call to do_open.

messages::do_get

virtual string_type do_get(catalog catval, int set, int message,
    const string_type& dflt) const;

The protected member function endeavors to obtain a message sequence from the message catalog catval. It may make use of set, message, and dflt in doing so. It returns a copy of dflt on failure. Otherwise, it returns a copy of the specified message sequence.

messages::do_open

virtual catalog do_open(const string& catname,
    const locale& loc) const;

The protected member function endeavors to open a message catalog whose name is catname. It may make use of the locale loc in doing so. It returns a value that compares less than zero on failure. Otherwise, the returned value can be used as the first argument on a later call to get. It should in any case be used as the argument on a later call to close.

messages::get

string_type get(catalog catval, int set, int message,
    const string_type& dflt) const;

The member function returns do_get(catval, set, message, dflt);.

messages::messages

explicit messages(size_t refs = 0);

The constructor initializes its base object with locale::facet(refs).

messages::open

catalog open(const string& catname,
    const locale& loc) const;

The member function returns do_open(catname, loc);.

messages::string_type

typedef basic_string<Elem> string_type;

The type describes a specialization of template class basic_string whose objects can store copies of the message sequences.

messages_base

class messages_base {
    typedef int catalog;
    };

The class describes a type common to all specializations of template class messages. The type catalog is a synonym for type int that describes the possible return values from messages::do_open.

messages_byname

template<class Elem>
    class messages_byname
        : public messages<Elem> {
public:
    explicit messages_byname(const char *locname,
        size_t refs = 0);
    explicit messages_byname(const string& locname,
        size_t refs = 0); [added with C++11]

protected:
    ~messages_byname();
    };

The template class describes an object that can serve as a locale facet of type messages<Elem>. Its behavior is determined by the named locale locname. Each constructor initializes its base object with messages<Elem>(refs).

money_base

class money_base {
    enum part {none, sign, space, symbol, value};
    struct pattern {
        char field[4];
        };
    };

The class describes an enumeration and a structure common to all specializations of template class moneypunct. The enumeration part describes the possible values in elements of the array field in the structure pattern. The values of part are:

money_get

template<class Elem,
    class InIt = istreambuf_iterator<Elem> >
    class money_get
        : public locale::facet {
public:
    typedef Elem char_type;
    typedef InIt iter_type;

    typedef basic_string<Elem> string_type;

    explicit money_get(size_t refs = 0);
    iter_type get(iter_type first, iter_type last,
        bool intl, ios_base& iosbase, ios_base::iostate& state,
            long double& val) const;
    iter_type get(iter_type first, iter_type last,
        bool intl, ios_base& iosbase, ios_base::iostate& state,
            string_type& val) const;

    static locale::id id;

protected:
    ~money_get();

    virtual iter_type do_get(iter_type first,
        iter_type last, bool intl, ios_base& iosbase,
        ios_base::iostate& state, string_type& val) const;
    virtual iter_type do_get(iter_type first,
        iter_type last, bool intl, ios_base& iosbase,
        ios_base::iostate& state, long double& val) const;
    };

The template class describes an object that can serve as a locale facet, to control conversions of sequences of type Elem to monetary values.

As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id.

money_get::char_type

typedef Elem char_type;

The type is a synonym for the template parameter Elem.

money_get::do_get

virtual iter_type do_get(iter_type first, iter_type last,
    bool intl, ios_base& iosbase, ios_base::iostate& state,
        string_type& val) const;
virtual iter_type do_get(iter_type first, iter_type last,
    bool intl, ios_base& iosbase, ios_base::iostate& state,
        long double& val) const;

The first virtual protected member function endeavors to match sequential elements beginning at first in the sequence [first, last) until it has recognized a complete, nonempty monetary input field. If successful, it converts this field to a sequence of one or more decimal digits (as described below), optionally preceded by a minus sign (as described below), to represent the amount, and stores the result in the string_type object val. It returns an iterator designating the first element beyond the monetary input field. Otherwise, the function stores an empty sequence in val and sets ios_base::failbit in state. It returns an iterator designating the first element beyond any prefix of a valid monetary input field. In either case, if the return value equals last, the function sets ios_base::eofbit in state.

The second virtual protected member function behaves the same as the first, except that if successful it converts the optionally-signed digit sequence (as described below) to a value of type long double and stores that value in val.

The format of a monetary input field is determined by two locale facets:

Specifically:

If the sign string (pfac.negative_sign or pfac.positive_sign) has more than one element, only the first element is matched where the element equal to money_base::sign appears in the format pattern (pfac.neg_format). Any remaining elements are matched at the end of the monetary input field. pfac.positive_sign is compared before pfac.negative_sign. If either string is empty, the sign is optional. If neither string has a first element that matches the next element in the monetary input field, the sign string is taken as empty; the sign is positive if pfac.positive_sign is empty; otherwise the sign is negative.

If iosbase.flags() & showbase is nonzero, the string pfac.curr_symbol must match where the element equal to money_base::symbol appears in the format pattern. Otherwise, if money_base::symbol occurs at the end of the format pattern, and if no elements of the sign string remain to be matched, the currency symbol is not matched. Otherwise, the currency symbol is optionally matched.

If no instances of pfac.thousands_sep() occur in the value portion of the monetary input field (where the element equal to money_base::value appears in the format pattern), no grouping constraint is imposed. Otherwise, any grouping constraints imposed by pfac.grouping() are enforced. Note that the resulting digit sequence represents an integer whose low-order pfac.frac_digits() decimal digits are considered to the right of the decimal point.

Zero or more white-space elements are matched where an element equal to money_base::none appears other than at the end of the format pattern. One or more white-space elements are matched where an element equal to money_base::space appears other than at the end of the format pattern. Otherwise, no internal white space is matched.

money_get::get

iter_type get(iter_type first, iter_type last,
    bool intl, ios_base& iosbase, ios_base::iostate& state,
        long double& val) const;
iter_type get(iter_type first, iter_type last,
    bool intl, ios_base& iosbase, ios_base::iostate& state,
        string_type& val) const;

Both member functions return do_get(first, last, intl, iosbase, state, val).

money_get::iter_type

typedef InIt iter_type;

The type is a synonym for the template parameter InIt.

money_get::money_get

explicit money_get(size_t refs = 0);

The constructor initializes its base object with locale::facet(refs).

money_get::string_type

typedef basic_string<Elem> string_type;

The type describes a specialization of template class basic_string whose objects can store sequences of elements from the source sequence.

money_put

template<class Elem,
    class OutIt = ostreambuf_iterator<Elem> >
    class money_put
        : public locale::facet {
public:
    typedef Elem char_type;
    typedef OutIt iter_type;
    typedef basic_string<Elem> string_type;

    explicit money_put(size_t refs = 0);

    iter_type put(iter_type next, bool intl, ios_base& iosbase,
        Elem fill, long double& val) const;
    iter_type put(iter_type next, bool intl, ios_base& iosbase,
        Elem fill, string_type& val) const;

    static locale::id id;

protected:
    ~money_put();

    virtual iter_type do_put(iter_type next, bool intl,
        ios_base& iosbase, Elem fill, string_type& val) const;
    virtual iter_type do_put(iter_type next, bool intl,
        ios_base& iosbase, Elem fill, long double& val) const;
    };

The template class describes an object that can serve as a locale facet, to control conversions of monetary values to sequences of type Elem.

As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id.

money_put::char_type

typedef Elem char_type;

The type is a synonym for the template parameter Elem.

money_put::do_put

virtual iter_type do_put(iter_type next, bool intl,
    ios_base& iosbase, Elem fill, string_type& val) const;
virtual iter_type do_put(iter_type next, bool intl,
    ios_base& iosbase, Elem fill, long double& val) const;

The first virtual protected member function generates sequential elements beginning at next to produce a monetary output field from the string_type object val. The sequence controlled by val must begin with one or more decimal digits (as described below), optionally preceded by a minus sign (as described below), which represents the amount. The function returns an iterator designating the first element beyond the generated monetary output field.

The second virtual protected member function behaves the same as the first, except that it effectively first converts val to an optionally-signed digit sequence (as described below), then converts that sequence as above.

The format of a monetary output field is determined by two locale facets:

Specifically:

If the sign string (pfac.negative_sign or pfac.positive_sign) has more than one element, only the first element is generated where the element equal to money_base::sign appears in the format pattern (pfac.neg_format or pfac.pos_format). Any remaining elements are generated at the end of the monetary output field.

If iosbase.flags() & showbase is nonzero, the string pfac.curr_symbol is generated where the element equal to money_base::symbol appears in the format pattern. Otherwise, no currency symbol is generated.

If no grouping constraints are imposed by pfac.grouping() (its first element has the value CHAR_MAX) then no instances of pfac.thousands_sep() are generated in the value portion of the monetary output field (where the element equal to money_base::value appears in the format pattern). If pfac.frac_digits() is zero, then no instance of pfac.decimal_point() is generated after the decimal digits. Otherwise, the resulting monetary output field places the low-order pfac.frac_digits() decimal digits to the right of the decimal point.

Padding occurs as for any numeric output field, except that if iosbase.flags() & iosbase.internal is nonzero, any internal padding is generated where the element equal to money_base::space or money_base::none appears in the format pattern, if it does appear. At least one padding element occurs where an element equal to space appears. Otherwise, internal padding occurs before the generated sequence. The padding character is fill.

The function calls iosbase.width(0) to reset the field width to zero.

money_put::put

iter_type put(iter_type next, bool intl, ios_base& iosbase,
    Elem fill, long double& val) const;
iter_type put(iter_type next, bool intl, ios_base& iosbase,
    Elem fill, string_type& val) const;

Both member functions return do_put(next, intl, iosbase, fill, val).

money_put::iter_type

typedef InIt iter_type;

The type is a synonym for the template parameter OutIt.

money_put::money_put

explicit money_put(size_t refs = 0);

The constructor initializes its base object with locale::facet(refs).

money_put::string_type

typedef basic_string<Elem> string_type;

The type describes a specialization of template class basic_string whose objects can store sequences of elements from the source sequence.

moneypunct


char_type · curr_symbol · decimal_point · do_curr_symbol · do_decimal_point · do_frac_digits · do_grouping · do_neg_format · do_negative_sign · do_pos_format · do_positive_sign · do_thousands_sep · frac_digits · grouping · moneypunct · neg_format · negative_sign · pos_format · positive_sign · string_type · thousands_sep


template<class Elem, bool Intl>
    class moneypunct
        : public locale::facet, public money_base {
public:
    typedef Elem char_type;
    typedef basic_string<Elem> string_type;

    explicit moneypunct(size_t refs = 0);

    Elem decimal_point() const;
    Elem thousands_sep() const;
    string grouping() const;
    string_type curr_symbol() const;
    string_type positive_sign() const;
    string_type negative_sign() const;
    int frac_digits() const;
    pattern pos_format(  oonst;
    pattern neg_format() const;
    static const bool intl = Intl;

    static locale::id id;

protected:
    ~moneypunct();

    virtual Elem do_decimal_point() const;
    virtual Elem do_thousands_sep() const;
    virtual string do_grouping() const;
    virtual string_type do_curr_symbol() const;
    virtual string_type do_positive_sign() const;
    virtual string_type do_negative_sign() const;
    virtual int do_frac_digits() const;
    virtual pattern do_pos_format() const;
    virtual pattern do_neg_format() const;
    };

The template class describes an object that can serve as a locale facet, to describe the sequences of type Elem used to represent a monetary input field or a monetary output field. If the template parameter Intl is true, international conventions are observed.

As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id.

The const static object intl stores the value of the template parameter Intl.

moneypunct::char_type

typedef Elem char_type;

The type is a synonym for the template parameter Elem.

moneypunct::curr_symbol

string_type curr_symbol() const;

The member function returns do_curr_symbol().

moneypunct::decimal_point

Elem decimal_point() const;

The member function returns do_decimal_point().

moneypunct::do_curr_symbol

string_type do_curr_symbol() const;

The protected virtual member function returns a locale-specific sequence of elements to use as a currency symbol.

moneypunct::do_decimal_point

Elem do_decimal_point() const;

The protected virtual member function returns a locale-specific element to use as a decimal-point.

moneypunct::do_frac_digits

int do_frac_digits() const;

The protected virtual member function returns a locale-specific count of the number of digits to display to the right of any decimal point.

moneypunct::do_grouping

string do_grouping() const;

The protected virtual member function returns a locale-specific rule for determining how digits are grouped to the left of any decimal point. The encoding is the same as for lconv::grouping.

moneypunct::do_neg_format

pattern do_neg_format() const;

The protected virtual member function returns a locale-specific rule for determining how to generate a monetary output field for a negative amount. Each of the four elements of pattern::field can have the values:

Components of a monetary output field are generated (and components of a monetary input field are matched) in the order in which these elements appear in pattern::field. Each of the values sign, symbol, value, and either none or space must appear exactly once. The value none must not appear first. The value space must not appear first or last. If Intl is true, the order is symbol, sign, none, then value.

The template version of moneypunct<Elem, Intl> returns {money_base::symbol, money_base::sign, money_base::value, money_base::none}.

moneypunct::do_negative_sign

string_type do_negative_sign() const;

The protected virtual member function returns a locale-specific sequence of elements to use as a negative sign.

moneypunct::do_pos_format

pattern do_pos_format() const;

The protected virtual member function returns a locale-specific rule for determining how to generate a monetary output field for a positive amount. (It also determines how to match the components of a monetary input field.) The encoding is the same as for do_neg_format.

The template version of moneypunct<Elem, Intl> returns {money_base::symbol, money_base::sign, money_base::value, money_base::none}.

moneypunct::do_positive_sign

string_type do_positive_sign() const;

The protected virtual member function returns a locale-specific sequence of elements to use as a positive sign.

moneypunct::do_thousands_sep

Elem do_thousands_sep() const;

The protected virtual member function returns a locale-specific element to use as a group separator to the left of any decimal point.

moneypunct::frac_digits

int frac_digits() const;

The member function returns do_frac_digits().

moneypunct::grouping

string grouping() const;

The member function returns do_grouping().

moneypunct::moneypunct

explicit moneypunct(size_t refs = 0);

The constructor initializes its base object with locale::facet(refs).

moneypunct::neg_format

pattern neg_format() const;

The member function returns do_neg_format().

moneypunct::negative_sign

string_type negative_sign() const;

The member function returns do_negative_sign().

moneypunct::pos_format

pattern pos_format() const;

The member function returns do_pos_format().

moneypunct::positive_sign

string_type positive_sign() const;

The member function returns do_positive_sign().

moneypunct::string_type

typedef basic_string<Elem> string_type;

The type describes a specialization of template class basic_string whose objects can store copies of the punctuation sequences.

moneypunct::thousands_sep

Elem thousands_sep() const;

The member function returns do_thousands_sep().

moneypunct_byname

template<class Elem, bool Intl>
    class moneypunct_byname
        : public moneypunct<Elem, Intl> {
public:
    explicit moneypunct_byname(const char *locname,
        size_t refs = 0);
    explicit moneypunct_byname(const string& locname,
        size_t refs = 0); [added with C++11]

protected:
    ~moneypunct_byname();
    };

The template class describes an object that can serve as a locale facet of type moneypunct<Elem, Intl>. Its behavior is determined by the named locale locname. Each constructor initializes its base object with moneypunct<Elem, Intl>(refs).

num_get

template<class Elem, class InIt = istreambuf_iterator<Elem> >
    class num_get
        : public locale::facet {
public:
    typedef Elem char_type;
    typedef InIt iter_type;

    explicit num_get(size_t refs = 0);

    iter_type get(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state,
            long& val) const;
    iter_type get(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state,
            unsigned long& val) const;

    iter_type get(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state,
            long long& val) const; [added with C++11]
    iter_type get(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state,
            unsigned long long& val) const; [added with C++11]

    iter_type get(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state,
            double& val) const;
    iter_type get(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state,
            long double& val) const;

    iter_type get(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state,
            void *& val) const;
    iter_type get(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state,
            bool& val) const;
    static locale::id id;

protected:
    ~num_get();

    virtual iter_type
        do_get(iter_type first, iter_type last,
            ios_base& iosbase, ios_base::iostate& state,
                long& val) const;
    virtual iter_type
        do_get(iter_type first, iter_type last,
            ios_base& iosbase, ios_base::iostate& state,
                unsigned long& val) const;

    virtual iter_type
        do_get(iter_type first, iter_type last,
            ios_base& iosbase, ios_base::iostate& state,
                long long& val) const; [added with C++11]
    virtual iter_type
        do_get(iter_type first, iter_type last,
            ios_base& iosbase, ios_base::iostate& state,
                unsigned long long& val) const; [added with C++11]

    virtual iter_type
        do_get(iter_type first, iter_type last,
            ios_base& iosbase, ios_base::iostate& state,
                double& val) const;
    virtual iter_type
        do_get(iter_type first, iter_type last,
            ios_base& iosbase, ios_base::iostate& state,
                long double& val) const;

    virtual iter_type
        do_get(iter_type first, iter_type last,
            ios_base& iosbase, ios_base::iostate& state,
                void *& val) const;
    virtual iter_type
        do_get(iter_type first, iter_type last,
            ios_base& iosbase, ios_base::iostate& state,
                bool& val) const;
    };

The template class describes an object that can serve as a locale facet, to control conversions of sequences of type Elem to numeric values.

As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id.

num_get::char_type

typedef Elem char_type;

The type is a synonym for the template parameter Elem.

num_get::do_get

virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        long& val) const;
virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        unsigned long& val) const;

virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        long long& val) const; [added with C++11]
virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        unsigned long long& val) const; [added with C++11]

virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        double& val) const;
virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        long double& val) const;

virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        void *& val) const;
virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        bool& val) const;

The first virtual protected member function endeavors to match sequential elements beginning at first in the sequence [first, last) until it has recognized a complete, nonempty integer input field. If successful, it converts this field to its equivalent value as type long, and stores the result in val. It returns an iterator designating the first element beyond the numeric input field. Otherwise, the function stores nothing in val and sets ios_base::failbit in state. It returns an iterator designating the first element beyond any prefix of a valid integer input field. In either case, if the return value equals last, the function sets ios_base::eofbit in state.

The integer input field is converted by the same rules used by the scan functions for matching and converting a series of char elements from a file. (Each such char element is assumed to map to an equivalent element of type Elem by a simple, one-to-one, mapping, as described below.) The equivalent scan conversion specification is determined as follows:

The format of a numeric input field is determined by two locale facets:

Specifically:

If no instances of pfac.thousands_sep() occur in the numeric input field, no grouping constraint is imposed. Otherwise, any grouping constraints imposed by pfac.grouping() are enforced and separators are removed before the scan conversion occurs.

The second virtual protected member function:

virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        unsigned long& val) const;

behaves the same as the first, except that it replaces a conversion specification of ld with lu. If successful it converts the numeric input field to a value of type unsigned long and stores that value in val.

The third virtual protected member function:

virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        long long& val) const; [added with C++11]

behaves the same as the first, except that it replaces a conversion specification of ld with lld. If successful it converts the numeric input field to a value of type long long and stores that value in val.

The fourth virtual protected member function:

virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        unsigned long long& val) const; [added with C++11]

behaves the same as the first, except that it replaces a conversion specification of ld with llu. If successful it converts the numeric input field to a value of type unsigned long long and stores that value in val.

The fifth virtual protected member function:

virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        double& val) const;

behaves the same as the first, except that it endeavors to match a complete, nonempty floating-point input field. pfac.decimal_point() determines the sequence that separates the integer digits from the fraction digits. The equivalent scan conversion specifier is lf.

The sixth virtual protected member function:

virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        long double& val) const;

behaves the same the third, except that the equivalent scan conversion specifier is Lf.

The seventh virtual protected member function:

virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        void *& val) const;

behaves the same the first, except that the equivalent scan conversion specifier is p.

The eighth virtual protected member function:

virtual iter_type do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        bool& val) const;

behaves the same as the first, except that it endeavors to match a complete, nonempty boolean input field. If successful it converts the boolean input field to a value of type bool and stores that value in val.

A boolean input field takes one of two forms. If iosbase.flags() & ios_base::boolalpha is false, it is the same as an integer input field, except that the converted value must be either 0 (for false) or 1 (for true). Otherwise, the sequence must match either pfac.falsename() (for false), or pfac.truename() (for true).

num_get::get

iter_type get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        long& val) const;
iter_type get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        unsigned long& val) const;

iter_type get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        long long& val) const; [added with C++11]
iter_type get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        unsigned long long& val) const; [added with C++11]

iter_type get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        double& val) const;
iter_type get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        long double& val) const;

iter_type get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        void *& val) const;
iter_type get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state,
        bool& val) const;

All member functions return do_get(first, last, iosbase, state, val).

num_get::iter_type

typedef InIt iter_type;

The type is a synonym for the template parameter InIt.

num_get::num_get

explicit num_get(size_t refs = 0);

The constructor initializes its base object with locale::facet(refs).

num_put

template<class Elem, class OutIt = ostreambuf_iterator<Elem> >
    class num_put
        : public locale::facet {
public:
    typedef Elem char_type;
    typedef OutIt iter_type;

    explicit num_put(size_t refs = 0);

    iter_type put(iter_type next, ios_base& iosbase,
        Elem fill, long val) const;
    iter_type put(iter_type next, ios_base& iosbase,
        Elem fill, unsigned long val) const;

    iter_type put(iter_type next, ios_base& iosbase,
        Elem fill, long long val) const; [added with C++11]
    iter_type put(iter_type next, ios_base& iosbase,
        Elem fill, unsigned long long val) const; [added with C++11]

    iter_type put(iter_type next, ios_base& iosbase,
        Elem fill, double val) const;
    iter_type put(iter_type next, ios_base& iosbase,
        Elem fill, long double val) const;

    iter_type put(iter_type next, ios_base& iosbase,
        Elem fill, const void *val) const;
    iter_type put(iter_type next, ios_base& iosbase,
        Elem fill, bool val) const;
    static locale::id id;

protected:
    ~num_put();

    virtual iter_type do_put(iter_type next, ios_base& iosbase,
        Elem fill, long val) const;
    virtual iter_type do_put(iter_type next, ios_base& iosbase,
        Elem fill, unsigned long val) const;

    virtual iter_type do_put(iter_type next, ios_base& iosbase,
        Elem fill, long long val) const; [added with C++11]
    virtual iter_type do_put(iter_type next, ios_base& iosbase,
        Elem fill, unsigned long long val) const; [added with C++11]

    virtual iter_type do_put(iter_type next, ios_base& iosbase,
        Elem fill, double val) const;
    virtual iter_type do_put(iter_type next, ios_base& iosbase,
        Elem fill, long double val) const;

    virtual iter_type do_put(iter_type next, ios_base& iosbase,
        Elem fill, const void *val) const;
    virtual iter_type do_put(iter_type next, ios_base& iosbase,
        Elem fill, bool val) const;
    };

The template class describes an object that can serve as a locale facet, to control conversions of numeric values to sequences of type Elem.

As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id.

num_put::char_type

typedef Elem char_type;

The type is a synonym for the template parameter Elem.

num_put::do_put

virtual iter_type do_put(iter_type next, ios_base& iosbase,
    Elem fill, long val) const;
virtual iter_type do_put(iter_type next, ios_base& iosbase,
    Elem fill, unsigned long val) const;

virtual iter_type do_put(iter_type next, ios_base& iosbase,
    Elem fill, long long val) const; [added with C++11]
virtual iter_type do_put(iter_type next, ios_base& iosbase,
    Elem fill, unsigned long long val) const; [added with C++11]

virtual iter_type do_put(iter_type next, ios_base& iosbase,
    Elem fill, double val) const;
virtual iter_type do_put(iter_type nextp ios_base& iosbase,
    Elem fill, long double val) const;

virtual iter_type do_put(iter_type nextp ios_base& iosbase,
    Elem fill, const void *val) const;
virtual iter_type do_put(iter_type next, ios_base& iosbase,
    Elem fill, bool val) const;

The first virtual protected member function generates sequential elements beginning at next to produce an integer output field from the value of val. The function returns an iterator designating the next place to insert an element beyond the generated integer output field.

The integer output field is generated by the same rules used by the print functions for generating a series of char elements to a file. (Each such char element is assumed to map to an equivalent element of type Elem by a simple, one-to-one, mapping, as described below.) Where a print function pads a field with either spaces or the digit 0, however, do_put instead uses fill. print conversion specification is determined as follows:

If iosbase.width() is nonzero, a field width of this value is prepended. The function then calls iosbase.width(0) to reset the field width to zero.

Padding occurs only if the minimum number of elements N required to specify the output field is less than iosbase.width(). Such padding consists of a sequence of N - width() copies of fill. Padding then occurs as follows:

Finally:

The format of an integer output field is further determined by two locale facets:

Specifically:

If no grouping constraints are imposed by pfac.grouping() (its first element has the value CHAR_MAX) then no instances of pfac.thousands_sep() are generated in the output field. Otherwise, separators are inserted after the print conversion occurs.

The second virtual protected member function:

virtual iter_type do_put(iter_type next, ios_base& iosbase,
    Elem fill, unsigned long val) const;

behaves the same as the first, except that it replaces a conversion specification of ld with lu.

The third virtual protected member function:

virtual iter_type do_put(iter_type next, ios_base& iosbase,
    Elem fill, long long val) const; [added with C++11]

behaves the same as the first, except that it replaces a conversion specification of ld with lld.

The fourth virtual protected member function:

virtual iter_type do_put(iter_type next, ios_base& iosbase,
    Elem fill, unsigned long long val) const; [added with C++11]

behaves the same as the first, except that it replaces a conversion specification of ld with llu.

The fifth virtual protected member function:

virtual iter_type do_put(iter_type next, ios_base& iosbase,
    Elem fill, double val) const;

behaves the same as the first, except that it produces a floating-point output field from the value of val. pfac.decimal_point() determines the sequence that separates the integer digits from the fraction digits. The equivalent print conversion specification is determined as follows:

If (iosbase.flags() & ios_base::floatfield) == ios_base::fixed, or if iosbase.precision() is greater than zero, a precision with the value iosbase.precision() is prepended to the conversion specification. Any padding behaves the same as for an integer output field. The padding character is fill. Finally:

The sixth virtual protected member function:

virtual iter_type do_put(iter_type next, ios_base& iosbase,
    Elem fill, long double val) const;

behaves the same the third, except that the qualifier l in the conversion specification is replaced with L.

The seventh virtual protected member function:

virtual iter_type do_put(iter_type next, ios_base& iosbase,
    Elem fill, const void *val) const;

behaves the same the first, except that the conversion specification is p, plus any qualifier needed to specify padding.

The eighth virtual protected member function:

virtual iter_type do_put(iter_type next, ios_base& iosbase,
    Elem fill, bool val) const;

behaves the same as the first, except that it generates a boolean output field from val.

A boolean output field takes one of two forms. If iosbase.flags() & ios_base::boolalpha is false, the member function returns do_put(next, iosbase, fill, (long)val), which typically produces a generated sequence of either 0 (for false) or 1 (for true). Otherwise, the generated sequence is either pfac.falsename() (for false), or pfac.truename() (for true).

num_put::put

iter_type put(iter_type next, ios_base& iosbase,
    Elem fill, long val) const;
iter_type put(iter_type next, ios_base& iosbase,
    Elem fill, unsigned long val) const;

iter_type put(iter_type next, ios_base& iosbase,
    Elem fill, long long val) const; [added with C++11]
iter_type put(iter_type next, ios_base& iosbase,
    Elem fill, unsigned long long val) const; [added with C++11]

iter_type put(iter_type iter_type next, ios_base& iosbase,
    Elem fill, double val) const;
iter_type put(iter_type next, ios_base& iosbase,
    Elem fill, long double val) const;

iter_type put(iter_type next, ios_base& iosbase,
    Elem fill, const void *val) const;
iter_type put(iter_type next, ios_base& iosbase,
    Elem fill, bool val) const;

All member functions return do_put(next, iosbase, fill, val).

num_put::iter_type

typedef InIt iter_type;

The type is a synonym for the template parameter OutIt.

num_put::num_put

explicit num_put(size_t refs = 0);

The constructor initializes its base object with locale::facet(refs).

numpunct


char_type · decimal_point · do_decimal_point · do_falsename · do_grouping · do_truename · do_thousands_sep · falsename · grouping · numpunct · string_type · thousands_sep · truename


template<class Elem>
    class numpunct
        : public locale::facet {
public:
    typedef Elem char_type;
    typedef basic_string<Elem> string_type;
    explicit numpunct(size_t refs = 0);
    Elem decimal_point() const;
    Elem thousands_sep() const;
    string grouping() const;
    string_type truename() const;
    string_type falsename() const;
    static locale::id id;

protected:
    ~numpunct();

    virtual Elem do_decimal_point() const;
    virtual Elem do_thousands_sep() const;
    virtual string do_grouping() const;
    virtual string_type do_truename() const;
    virtual string_type do_falsename() const;
    };

The template class describes an object that can serve as a locale facet, to describe the sequences of type Elem used to represent the input fields matched by num_get or the output fields generated by num_get.

As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id.

numpunct::char_type

typedef Elem char_type;

The type is a synonym for the template parameter Elem.

numpunct::decimal_point

Elem decimal_point() const;

The member function returns do_decimal_point().

numpunct::do_decimal_point

Elem do_decimal_point() const;

The protected virtual member function returns a locale-specific element to use as a decimal-point.

numpunct::do_falsename

string_type do_falsename() const;

The protected virtual member function returns a locale-specific sequence to use as a text representation of the value false.

numpunct::do_grouping

string do_grouping() const;

The protected virtual member function returns a locale-specific rule for determining how digits are grouped to the left of any decimal point. The encoding is the same as for lconv::grouping.

numpunct::do_thousands_sep

Elem do_thousands_sep() const;

The protected virtual member function returns a locale-specific element to use as a group separator to the left of any decimal point.

numpunct::do_truename

string_type do_truename() const;

The protected virtual member function returns a locale-specific sequence to use as a text representation of the value true.

numpunct::falsename

string_type falsename() const;

The member function returns do_falsename().

numpunct::grouping

string grouping() const;

The member function returns do_grouping().

numpunct::numpunct

explicit numpunct(size_t refs = 0);

The constructor initializes its base object with locale::facet(refs).

numpunct::string_type

typedef basic_string<Elem> string_type;

The type describes a specialization of template class basic_string whose objects can store copies of the punctuation sequences.

numpunct::thousands_sep

Elem thousands_sep() const;

The mmmber function returns do_thousands_sep().

numpunct::truename

string_type falsename() const;

The member function returns do_truename().

numpunct_byname

template<class Elem>
    class numpunct_byname
        : public numpunct<Elem> {
public:
    explicit numpunct_byname(const char *locname,
        size_t refs = 0);
    explicit numpunct_byname(const string& locname,
        size_t refs = 0); [added with C++11]

protected:
    ~numpunct_byname();
    };

The template class describes an object that can serve as a locale facet of type numpunct<Elem>. Its behavior is determined by the named locale locname. Each constructor initializes its base object with numpunct<Elem>(refs).

time_base

class time_base {
public:
    enum dateorder {no_order, dmy, mdy, ymd, ydm};
    };

The class serves as a base class for facets of template class time_get. It defines just the enumeration type dateorder and several constants of this type. Each of the constants characterizes a different way to order the components of a date. The constants are:

time_get

template<class Elem, class InIt = istreambuf_iterator<Elem> >
    class time_get
        : public locale::facet, time_base {
public:
    typedef Elem char_type;
    typedef InIt iter_type;

    explicit time_get(size_t refs = 0);

    dateorder date_order() const;
    iter_type get_time(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state, tm *pt) const;
    iter_type get_date(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state, tm *pt) const;
    iter_type get_weekday(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state, tm *pt) const;
    iter_type get_monthname(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state, tm *pt) const;
    iter_type get_year(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state, tm *pt) const;

    iter_type get(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state, tm *pt,
        char fmt, char mod) const; [added with C++11]
    iter_type get(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state, tm *pt,
        char_type *fmt_first, char_type *fmt_last) const; [added with C++11]

    static locale::id id;

protected:
    ~time_get();

    virtual dateorder do_date_order() const;
    virtual iter_type
        do_get_time(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state, tm *pt) const;
    virtual iter_type
        do_get_date(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state, tm *pt) const;
    virtual iter_type
        do_get_weekday(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state, tm *pt) const;
    virtual iter_type
        do_get_monthname(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state, tm *pt) const;
    virtual iter_type
        do_get_year(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state, tm *pt) const;

    virtual iter_type
        do_get(iter_type first, iter_type last,
        ios_base& iosbase, ios_base::iostate& state, tm *pt,
        char fmt, char mod) const; [added with C++11]
    };

The template class describes an object that can serve as a locale facet, to control conversions of sequences of type Elem to time values.

As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id.

time_get::char_type

typedef Elem char_type;

The type is a synonym for the template parameter Elem.

time_get::date_order

dateorder date_order() const;

The member function returns date_order().

time_get::do_date_order

virtual dateorder do_date_order() const;

The virtual protected member function returns a value of type time_base::dateorder, which describes the order in which date components are matched by do_get_date.

time_get::do_get

virtual iter_type
    do_get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state, tm *pt,
    char fmt, char mod) const; [added with C++11]

The virtual member function converts and skips one or more input elements in the range [first, last) to determine the values stored in one or more members of *pt. A conversion failure sets ios_base::failbit in state and returns first. Otherwise, the function returns an iterator designating the first unconverted element.

The conversion specifiers are:

Any other conversion specifier sets ios_base::failbit in state and returns. In this implementation, any modifier has no effect.

time_get::do_get_date

virtual iter_type
    do_get_date(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state, tm *pt) const;

The virtual protected member function endeavors to match sequential elements beginning at first in the sequence [first, last) until it has recognized a complete, nonempty date input field. If successful, it converts this field to its equivalent value as the components tm::tm_mon, tm::tm_day, and tm::tm_year, and stores the results in pt->tm_mon, pt->tm_day and pt->tm_year, respectively. It returns an iterator designating the first element beyond the date input field. Otherwise, the function sets ios_base::failbit in state. It returns an iterator designating the first element beyond any prefix of a valid date input field. In either case, if the return value equals last, the function sets ios_base::eofbit in state.

In this implementation, the date input field is assumed to have three fields:

The fields are separated by optional spaces, followed by an optional colon, comma, or slash, followed by optional spaces. The order of the fields is as specified by time_get::date_order(), except that the value no_order is taken as mdy and any sequence matched by get_monthname is always taken as a month.

time_get::do_get_monthname

virtual iter_type
    do_get_monthname(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state, tm *pt) const;

The virtual protected member function endeavors to match sequential elements beginning at first in the sequence [first, last) until it has recognized a complete, nonempty month input field. If successful, it converts this field to its equivalent value as the component tm::tm_mon, and stores the result in pt->tm_mon. It returns an iterator designating the first element beyond the month input field. Otherwise, the function sets ios_base::failbit in state. It returns an iterator designating the first element beyond any prefix of a valid month input field. In either case, if the return value equals last, the function sets ios_base::eofbit in state.

The month input field is a sequence that matches the longest of a set of locale-specific sequences, such as: Jan, January, Feb, February, etc. The converted value is the number of months since January.

time_get::do_get_time

virtual iter_type
    do_get_time(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state, tm *pt) const;

The virtual protected member function endeavors to match sequential elements beginning at first in the sequence [first, last) until it has recognized a complete, nonempty time input field. If successful, it converts this field to its equivalent value as the components tm::tm_hour, tm::tm_min, and tm::tm_sec, and stores the results in pt->tm_hour, pt->tm_min and pt->tm_sec, respectively. It returns an iterator designating the first element beyond the time input field. Otherwise, the function sets ios_base::failbit in state. It returns an iterator designating the first element beyond any prefix of a valid time input field. In either case, if the return value equals last, the function sets ios_base::eofbit in state.

In this implementation, the time input field has the form HH:MM:SS, where:

time_get::do_get_weekday

virtual iter_type
    do_get_weekday(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state, tm *pt) const;

The virtual protected member function endeavors to match sequential elements beginning at first in the sequence [first, last) until it has recognized a complete, nonempty weekday input field. If successful, it converts this field to its equivalent value as the component tm::tm_wday, and stores the result in pt->tm_wday. It returns an iterator designating the first element beyond the weekday input field. Otherwise, the function sets ios_base::failbit in state. It returns an iterator designating the first element beyond any prefix of a valid weekday input field. In either case, if the return value equals last, the function sets ios_base::eofbit in state.

The weekday input field is a sequence that matches the longest of a set of locale-specific sequences, such as: Sun, Sunday, Mon, Monday, etc. The converted value is the number of days since Sunday.

time_get::do_get_year

virtual iter_type
    do_get_year(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state, tm *pt) const;

The virtual protected member function endeavors to match sequential elements beginning at first in the sequence [first, last) until it has recognized a complete, nonempty year input field. If successful, it converts this field to its equivalent value as the component tm::tm_year, and stores the result in pt->tm_year. It returns an iterator designating the first element beyond the year input field. Otherwise, the function sets ios_base::failbit in state. It returns an iterator designating the first element beyond any prefix of a valid year input field. In either case, if the return value equals last, the function sets ios_base::eofbit in state.

The year input field is a sequence of decimal digits whose corresponding numeric value must be in the range [1900, 2036). The stored value is this value minus 1900. In this implementation, values in the range [69, 136) represent the range of years [1969, 2036). Values in the range [0, 69) are also permissible, but may represent either the range of years [1900, 1969) or [2000, 2069), depending on the specific translation environment.

time_get::get

iter_type get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state, tm *pt,
    char fmt, char mod) const; [added with C++11]
iter_type get(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state, tm *pt,
    char_type *fmt_first, char_type *fmt_last) const; [added with C++11]

The first member function returns do_get(first, last, iosbase, state, pt, fmt, mod).

The second member function calls do_get under the control of the format delimited by [fmt_first, fmt_last). It treats the format as a sequence of fields, each of which determines the conversion of zero or more input elements delimited by [first, last). It returns an iterator designating the first unconverted element.

Elements in the format are determined by the locale facet cfac returned by the call use_facet< ctype<Elem> >(iosbase.getloc()). Specifically:

There are three kinds of fields:

time_get::get_date

iter_type get_date(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state, tm *pt) const;

The member function returns do_get_date(first, last, iosbase, state, pt).

time_get::get_monthname

iter_type get_monthname(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state, tm *pt) const;

The member function returns do_get_monthname(first, last, iosbase, state, pt).

time_get::get_time

iter_type get_time(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state, tm *pt) const;

The member function returns do_get_time(first, last, iosbase, state, pt).

time_get::get_weekday

iter_type get_weekday(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state, tm *pt) const;

The member function returns do_get_weekday(first, last, iosbase, state, pt).

time_get::get_year

iter_type get_year(iter_type first, iter_type last,
    ios_base& iosbase, ios_base::iostate& state, tm *pt) const;

The member function returns do_get_year(first, last, iosbase, state, pt).

time_get::iter_type

typedef InIt iter_type;

The type is a synonym for the template parameter InIt.

time_get::time_get

explicit time_get(size_t refs = 0);

The constructor initializes its base object with locale::facet(refs).

time_get_byname

template<class Elem, class InIt>
    class time_get_byname
        : public time_get<Elem, InIt> {
public:
    explicit time_get_byname(const char *locname,
        size_t refs = 0);
    explicit time_get_byname(const string& locname,
        size_t refs = 0); [added with C++11]

protected:
    ~time_get_byname();
    };

The template class describes an object that can serve as a locale facet of type time_get<Elem, InIt>. Its behavior is determined by the named locale locname. Each constructor initializes its base object with time_get<Elem, InIt>(refs).

time_put

template<class Elem, class OutIt = ostreambuf_iterator<Elem> >
    class time_put
        : public locale::facet {
public:
    typedef Elem char_type;
    typedef OutIt iter_type;

    explicit time_put(size_t refs = 0);

    iter_type put(iter_type next, ios_base& iosbase,
        char_type fill, const tm *pt, char fmt, char mod = 0) const;
    iter_type put(iter_type next, ios_base& iosbase,
        char_type fill, const tm *pt, const Elem *first, const Elem *last) const;

    static locale::id id;

protected:
    ~time_put();

    virtual iter_type do_put(iter_type next, ios_base& iosbase,
        char_type fill, const tm *pt, char fmt, char mod = 0) const;
    };

The template class describes an object that can serve as a locale facet, to control conversions of time values to sequences of type Elem.

As with any locale facet, the static object id has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id.

time_put::char_type

typedef Elem char_type;

The type is a synonym for the template parameter Elem.

time_put::do_put

virtual iter_type do_put(iter_type next, ios_base& iosbase,
    char_type fill, const tm *pt, char fmt, char mod = 0) const;

The virtual protected member function generates sequential elements beginning at next from time values stored in the object *pt, of type tm. The function returns an iterator designating the next place to insert an element beyond the generated output.

The output is generated by the same rules used by strftime, with a last argument of pt, for generating a series of char elements into an array. (Each such char element is assumed to map to an equivalent element of type Elem by a simple, one-to-one, mapping.) If mod equals zero, the effective format is "%F", where F is replaced by fmt. Otherwise, the effective format is "%MF", where M is replaced by mod.

The parameter fill is not used.

time_put::put

iter_type put(iter_type next, ios_base& iosbase,
    char_type fill, const tm *pt, char fmt, char mod = 0) const;
iter_type put(iter_type next, ios_base& iosbase,
    char_type fill, const tm *pt, const Elem *first, const Elem *last) const;

The first member function returns do_put(next, iosbase, fill, pt, fmt, mod).

The second member function treats the sequence [first, last) as a sequence of format fields. It copies to *next++ any element in the sequence other than a percent (%). For a percent followed by a character C in the sequence the function instead evaluates next = do_put(next, iosbase, fill, pt, C, 0) and skips past C. If, however, C is a qualifier character from the set [EOQ#], followed by a character C2 in the sequence, the function instead evaluates next = do_put(next, iosbase, fill, pt, C2, C) and skips past C2.

Elements in the format are determined by the locale facet cfac returned by the call use_facet< ctype<Elem> >(iosbase.getloc()). Specifically, cfac.narrow(ch) converts the values ch of type Elem to values of type char to determine elements of the format fields.

time_put::iter_type

typedef InIt iter_type;

The type is a synonym for the template parameter OutIt.

time_put::time_put

explicit time_put(size_t refs = 0);

The constructor initializes its base object with locale::facet(refs).

time_put_byname

template<class Elem, class OutIt>
    class time_put_byname
        : public time_put<Elem, OutIt> {
public:
    explicit time_put_byname(const char *locname,
        size_t refs = 0);
    explicit time_put_byname(const string& locname,
        size_t refs = 0); [added with C++11]

protected:
    ~time_put_byname();
    };

The template class describes an object that can serve as a locale facet of type time_put<Elem, OutIt>. Its behavior is determined by the named locale locname. Each constructor initializes its base object with time_put<Elem, OutIt>(refs).

tolower

template<class Elem>
    Elem tolower(Elem ch, const locale& loc) const;

The template function returns use_facet< ctype<Elem> >(loc). tolower(ch).

toupper

template<class Elem>
    Elem toupper(Elem ch, const locale& loc) const;

The template function returns use_facet< ctype<Elem> >(loc). toupper(ch).

use_facet

template<class Facet>
    const Facet& use_facet(const locale& loc);

The template function returns a reference to the locale facet of class Facet listed within the locale object loc. If no such object is listed, the function throws an object of class bad_cast.

wbuffer_convert

template<class Codecvt,
    class Elem = wchar_t,
    class Tr = char_traits<Elem> >
    class wbuffer_convert
        : public basic_streambuf<Elem, Tr>
    {
public:
    typedef typename Codecvt::state_type state_type;

    wbuffer_convert(streambuf *bytebuf = 0,
        const Codecvt *pcvt = new Codecvt,
        state_type state = state_type());

    streambuf *rdbuf() const;
    streambuf *rdbuf(streambuf *bytebuf);

    state_type state() const;

    // exposition only
private:
    streambuf *bufptr;
    const Codecvt *cvtptr;
    state_type cvtstate;
    };

The template class describes a stream buffer that controls the transmission of elements of type Elem, whose character traits are described by the class Tr, to and from a byte stream buffer of type streambuf. Conversion between a sequence of Elem values and multibyte sequences is performed by an object of class Codecvt<Elem, char, mbstate_t>, which meets the requirements of the standard code-conversion facet codecvt<Elem, char, mbstate_t>. For example, to write UTF-8 encoded wide characters to the file named myfile.txt:

#include <fstream>
#include <locale>
#include <codecvt>
.....
    {   // write Hello as one line to a file
    ofstream bytestream("myfile.txt"); // open file as byte stream
    wbuffer_convert<
        codecvt_utf8<wchar_t> >
            mybuf(bytestream.rdbuf());  // construct wide stream buffer object
    wostream mystr(&mybuf); // construct wide ostream object
    mystr << L"Hello" << endl;
    }

An object of this template class stores:

wbuffer_convert::state

state_type state() const;

The member function returns cvtstate.

wbuffer_convert::rdbuf

streambuf *rdbuf() const;
streambuf *rdbuf(streambuf *bytebuf);

The first member function returns bufptr. The second member function stores bytebuf in bufptr.

wbuffer_convert::wbuffer_convert

wbuffer_convert(streambuf *bytebuf = 0,
    const Codecvt *pcvt = new Codecvt,
    state_type state = state_type());

The constructor constructs a stream buffer object, initializes bufptr to bytebuf, initializes cvtptr to pcvt, and initializes cvtstate to state.

wbuffer_convert::state_type

typedef typename Codecvt::state_type state_type;

The type is a synonym for Codecvt::state_type.

wstring_convert

template<class Codecvt,
    class Elem = wchar_t,
    class Walloc = allocator<Elem>,
    class Balloc = allocator<char> >
    class wstring_convert
    {
    typedef basic_string<char, char_traits<char>, Balloc>
        byte_string;
    typedef basic_string<Elem, char_traits<Elem>, Walloc>
        wide_string;
    typedef typename Codecvt::state_type state_type;
    typedef typename wide_string::traits_type::int_type int_type;

    wstring_convert(const Codecvt *pcvt = new Codecvt);
    wstring_convert(const Codecvt *pcvt, state_type state);
    wstring_convert(const byte_string& byte_err,
        const wide_string& wide_err = wide_string());

    wide_string from_bytes(char byte);
    wide_string from_bytes(const char *ptr);
    wide_string from_bytes(const byte_string& str);
    wide_string from_bytes(const char *first, const char *last);

    byte_string to_bytes(Elem wchar);
    byte_string to_bytes(const _Elem *wptr);
    byte_string to_bytes(const wide_string& wstr);
    byte_string to_bytes(const Elem *first, const Elem *last);

    size_t converted() const;
    state_type state() const;

    // exposition only
private:
    byte_string byte_err_string;
    wide_string wide_err_string;
    const Codecvt *cvtptr;
    state_type cvtstate;
    size_t cvtcount;
    };

The template class describes an object that controls conversions between wide string objects of class basic_string<Elem> and byte string objects of class basic_string<char> (also known as string). The template class defines the types wide_string and byte_string as synonyms for these two types. Conversion between a sequence of Elem values (stored in a wide_string object) and multibyte sequences (stored in a byte_string object) is performed by an object of class Codecvt<Elem, char, mbstate_t>, which meets the requirements of the standard code-conversion facet codecvt<Elem, char, mbstate_t>. For example, to write UTF-8 encoded wide characters to the file named myfile.txt:

#include <fstream>
#include <locale>
#include <codecvt>
#include <string>
.....
    {   // write Hello as one line to a file
    std::ofstream bytestream("myfile.txt"); // open file as byte stream
    std::wstring_convert<
        std::codecvt_utf8<wchar_t>> myconv;
    std::string mbstring = myconv.to_bytes(L"Hello\n");
    mystr << mbstring;
    }

An object of this template class stores:

wstring_convert::byte_string

typedef basic_string<char, char_traits<char>, Balloc>
    byte_string;

The type is a synonym for basic_string<char, char_traits<char>, Balloc>.

wstring_convert::converted

size_t converted() const;

The member function returns cvtcount.

wstring_convert::from_bytes

wide_string from_bytes(char byte);
wide_string from_bytes(const char *ptr);
wide_string from_bytes(const byte_string& str);
wide_string from_bytes(const char *first, const char *last);

The first member function converts the single-element sequence byte to a wide string. The second member function converts the nul-terminated sequence beginning at ptr to a wide string. The third member function converts the sequence stored in str to a wide string. The fourth member function converts the sequence defined by the range [first, last) to a wide string.

In all cases:

wstring_convert::int_type

typedef typename wide_string::traits_type::int_type int_type;

The type is a synonym for wide_string::traits_type::int_type.

wstring_convert::state

state_type state() const;

The member function returns cvtstate.

wstring_convert::state_type

typedef typename Codecvt::state_type state_type;

The type is a synonym for Codecvt::state_type.

wstring_convert::to_bytes

byte_string to_bytes(Elem wchar);
byte_string to_bytes(const _Elem *wptr);
byte_string to_bytes(const wide_string& wstr);
byte_string to_bytes(const Elem *first, const Elem *last);

The first member function converts the single-element sequence wchar to a byte string. The second member function converts the nul-terminated sequence beginning at wptr to a byte string. The third member function converts the sequence stored in wstr to a byte string. The fourth member function converts the sequence defined by the range [first, last) to a byte string.

In all cases:

wstring_convert::wide_string

typedef basic_string<Elem, char_traits<Elem>, Walloc>
    wide_string;

The type is a synonym for basic_string<Elem, char_traits<Elem>, Walloc>.

wstring_convert::wstring_convert

wstring_convert(const Codecvt *pcvt = new Codecvt);
wstring_convert(const Codecvt *pcvt, state_type state);
wstring_convert(const byte_string& byte_err,
    const wide_string& wide_err = wide_string());

The first constructor stores pcvt in cvtptr and default values in cvtstate, byte_err_string, and wide_err_string. The second constructor stores pcvt in cvtptr, state in cvtstate, and default values in byte_err_string and wide_err_string; moreover the stored state is retained between calls to from_bytes and to_bytes. The third constructor stores new Codecvt in cvtptr, state_type() in cvtstate, byte_err in byte_err_string, and wide_err in wide_err_string.


See also the Table of Contents and the Index.

Copyright © 1992-2013 by P.J. Plauger. All rights reserved.