template<class From, class To, class State>
class codecvt : public locale::facet, public codecvt_base {
public:
typedef From from_type;
typedef To to_type;
typedef State state_type;
explicit codecvt(size_t refs = 0);
result in(State& state,
const To *first1, const To *last1, const To *next1,
From *first2, From *last2, From *next2);
result out(State& state,
const From *first1, const From *last1, const From *next1,
To *first2, To *last2, To *next2);
bool always_noconv() const throw();
int max_length() const throw();
int length(State& state,
From *first1, const From *last1, size_t _N2) const throw();
int encoding() const throw();
static locale::id id;
protected:
~codecvt();
virtual result do_in(State& state,
const To *first1, const To *last1, const To *next1,
From *first2, From *last2, From *next2);
virtual result do_out(State& state,
const From *first1, const From *last1, const From *next1,
To *first2, To *last2, To *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(State& state,
From *first1, const From *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 From
and a sequence of values of type To
. The class State
characterizes the transformation -- and an
object of class State
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
do_out
always return codecvt_base::
noconv
. The Standard C++ library defines
an explicit specialization, however, that is more useful:
codecvt<wchar_t, char, mbstate_t
which converts between wchar_t
and char sequences.