STL/codecvt

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

Содержание

[править] codecvt Class

[править] Описание

A template class that describes an object that can serve as a locale facet that is able to control conversions between a sequence of values used to encode characters within the program and a sequence of values used to encode characters outside the program.

template <
   class CharType,
   class Byte,
   class StateType,
> 
class codecvt : public codecvt_base

CharType

  • The type used within a program to encode characters.

Byte

  • A type used to encode characters outside a program.

StateType

  • A type that can be used to represent intermediate states of a conversion between internal and external types of character representations.

The internal encoding uses a representation with a fixed number of bytes per character, usually either type char or type wchar_t.

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 an explicit specialization, however, that is more useful:

template<> codecvt<wchar_t, char, mbstate_t>

which converts between wchar_t and char sequences.


[править] Конструкторы

codecvt

The constructor for objects of class codecvt that serves as a locale facet to handle conversions.

[править] Typedefs

extern_type

A character type that is used for external representations.

intern_type

A character type that is used for internal representations.

state_type

A character type that is used to represent intermediate states during conversions between internal and external representations.

[править] Функции члены

always_noconv

Tests whether no conversions need be done.

do_always_noconv

A virtual function called to test whether no conversions need be done.

do_encoding

A virtual function that tests if the encoding of the Byte stream is state dependent, whether the ratio between the Bytes used and the CharTypes produced is constant, and, if so, determines the value of that ratio.

do_in

A virtual function called to convert a sequence of internal Bytes to a sequence of external CharTypes.

do_length

A virtual function that determines how many Bytes from a given sequence of external Bytes produce not more than a given number of internal CharTypes and returns that number of Bytes.

do_max_length

A virtual function that returns the maximum number of external Bytes necessary to produce one internal CharType.

do_out

A virtual function called to convert a sequence of internal CharTypes to a sequence of external Bytes.

do_unshift

A virtual function called to provide the Bytes needed in a state-dependent conversion to complete the last character in a sequence of Bytes.

in

Converts an external representation of a sequence of Bytes to an internal representation of a sequence of CharTypes.

length

Determines how many Bytes from a given sequence of external Bytes produce not more than a given number of internal CharTypes and returns that number of Bytes.

encoding

Tests if the encoding of the Byte stream is state dependent, whether the ratio between the Bytes used and the CharTypes produced is constant, and, if so, determines the value of that ratio.

max_length

Returns the maximum number of external Bytes necessary to produce one internal CharType.

out

Converts a sequence of internal CharTypes to a sequence of external Bytes.

unshift

Provides the external Bytes needed in a state-dependent conversion to complete the last character in the sequence of Bytes.