STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Protected Member Functions | List of all members
stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode > Class Template Reference
Inheritance diagram for stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >:

Public Types

typedef _STD codecvt< _Elem, char, _Statype_Mybase
 
typedef _Mybase::result result
 
typedef char _Byte
 
typedef _Elem intern_type
 
typedef _Byte extern_type
 
typedef _Statype state_type
 

Public Member Functions

 codecvt_utf8 (size_t _Refs=0)
 
virtual ~codecvt_utf8 () _NOEXCEPT
 

Protected Member Functions

virtual result do_in (_Statype &_State, const _Byte *_First1, const _Byte *_Last1, const _Byte *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
 
virtual result do_out (_Statype &_State, const _Elem *_First1, const _Elem *_Last1, const _Elem *&_Mid1, _Byte *_First2, _Byte *_Last2, _Byte *&_Mid2) const
 
virtual result do_unshift (_Statype &, _Byte *_First2, _Byte *, _Byte *&_Mid2) const
 
virtual int do_length (_Statype &_State, const _Byte *_First1, const _Byte *_Last1, size_t _Count) const _THROW0()
 
virtual bool do_always_noconv () const _THROW0()
 
virtual int do_max_length () const _THROW0()
 
virtual int do_encoding () const _THROW0()
 

Member Typedef Documentation

template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
typedef char stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::_Byte
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
typedef _STD codecvt<_Elem, char, _Statype> stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::_Mybase
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
typedef _Byte stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::extern_type
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
typedef _Elem stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::intern_type
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
typedef _Mybase::result stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::result
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
typedef _Statype stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::state_type

Constructor & Destructor Documentation

template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::codecvt_utf8 ( size_t  _Refs = 0)
inlineexplicit
40  : _Mybase(_Refs)
41  { // construct with ref count
42  }
_STD codecvt< _Elem, char, _Statype > _Mybase
Definition: utf8:32
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
virtual stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::~codecvt_utf8 ( )
inlinevirtual
45  { // destroy the object
46  }

Member Function Documentation

template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
virtual bool stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::do_always_noconv ( ) const
inlineprotectedvirtual
211  { // return true if conversions never change input
212  return (false);
213  }
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
virtual int stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::do_encoding ( ) const
inlineprotectedvirtual
222  { // return length of code sequence (from codecvt)
223  return ((_Mode & (_STD consume_header | _STD generate_header)) != 0
224  ? -1 : 0); // -1 => state dependent, 0 => varying length
225  }
Definition: codecvt:25
Definition: codecvt:24
_Check_return_ _In_z_ wchar_t const * _Mode
Definition: corecrt_wstdio.h:133
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
virtual result stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::do_in ( _Statype _State,
const _Byte _First1,
const _Byte _Last1,
const _Byte *&  _Mid1,
_Elem *  _First2,
_Elem *  _Last2,
_Elem *&  _Mid2 
) const
inlineprotectedvirtual
52  { // convert bytes [_First1, _Last1) to [_First2, _Last)
53  char *_Pstate = (char *)&_State;
54  _Mid1 = _First1;
55  _Mid2 = _First2;
56 
57  for (; _Mid1 != _Last1 && _Mid2 != _Last2; )
58  { // convert a multibyte sequence
59  unsigned char _By = (unsigned char)*_Mid1;
60  unsigned long _Ch;
61  int _Nextra;
62 
63  if (_By < 0x80)
64  _Ch = _By, _Nextra = 0;
65  else if (_By < 0xc0)
66  { // 0x80-0xdf not first byte
67  ++_Mid1;
68  return (_Mybase::error);
69  }
70  else if (_By < 0xe0)
71  _Ch = _By & 0x1f, _Nextra = 1;
72  else if (_By < 0xf0)
73  _Ch = _By & 0x0f, _Nextra = 2;
74  else if (_By < 0xf8)
75  _Ch = _By & 0x07, _Nextra = 3;
76  else
77  _Ch = _By & 0x03, _Nextra = _By < 0xfc ? 4 : 5;
78 
79  if (_Nextra == 0)
80  ++_Mid1;
81  else if (_Last1 - _Mid1 < _Nextra + 1)
82  break; // not enough input
83  else
84  for (++_Mid1; 0 < _Nextra; --_Nextra, ++_Mid1)
85  if ((_By = (unsigned char)*_Mid1) < 0x80 || 0xc0 <= _By)
86  return (_Mybase::error); // not continuation byte
87  else
88  _Ch = _Ch << 6 | (_By & 0x3f);
89 
90  if (*_Pstate == 0)
91  { // first time, maybe look for and consume header
92  *_Pstate = 1;
93 
94  if ((_Mode & _STD consume_header) != 0 && _Ch == 0xfeff)
95  { // drop header and retry
96  result _Ans = do_in(_State, _Mid1, _Last1, _Mid1,
97  _First2, _Last2, _Mid2);
98 
99  if (_Ans == _Mybase::partial)
100  { // roll back header determination
101  *_Pstate = 0;
102  _Mid1 = _First1;
103  }
104  return (_Ans);
105  }
106  }
107 
108  if (_Maxcode < _Ch)
109  return (_Mybase::error); // code too large
110  *_Mid2++ = (_Elem)_Ch;
111  }
112 
113  return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
114  }
_Mybase::result result
Definition: utf8:33
Definition: codecvt:24
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
_In_ size_t _Deref_pre_opt_z_ char const _In_ size_t _Inout_ mbstate_t * _State
Definition: wchar.h:78
_Check_return_ _In_z_ wchar_t const * _Mode
Definition: corecrt_wstdio.h:133
unsigned char
Definition: mbstring.h:107
virtual result do_in(_Statype &_State, const _Byte *_First1, const _Byte *_Last1, const _Byte *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
Definition: utf8:49
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
virtual int stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::do_length ( _Statype _State,
const _Byte _First1,
const _Byte _Last1,
size_t  _Count 
) const
inlineprotectedvirtual
180  { // return min(_Count, converted length of bytes [_First1, _Last1))
181  size_t _Wchars = 0;
182  _Statype _Mystate = _State;
183 
184  for (; _Wchars < _Count && _First1 != _Last1; )
185  { // convert another wide character
186  const _Byte *_Mid1;
187  _Elem *_Mid2;
188  _Elem _Ch;
189 
190  switch (do_in(_Mystate, _First1, _Last1, _Mid1,
191  &_Ch, &_Ch + 1, _Mid2))
192  { // test result of single wide-char conversion
193  case _Mybase::noconv:
194  return ((int)(_Wchars + (_Last1 - _First1)));
195 
196  case _Mybase::ok:
197  if (_Mid2 == &_Ch + 1)
198  ++_Wchars; // replacement do_in might not convert one
199  _First1 = _Mid1;
200  break;
201 
202  default:
203  return ((int)_Wchars); // error or partial
204  }
205  }
206 
207  return ((int)_Wchars);
208  }
char _Byte
Definition: utf8:34
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
_In_ size_t _Deref_pre_opt_z_ char const _In_ size_t _Inout_ mbstate_t * _State
Definition: wchar.h:78
virtual result do_in(_Statype &_State, const _Byte *_First1, const _Byte *_Last1, const _Byte *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
Definition: utf8:49
_Diff _Count
Definition: algorithm:1941
_CSTD mbstate_t _Statype
Definition: codecvt:28
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
virtual int stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::do_max_length ( ) const
inlineprotectedvirtual
216  { // return maximum length required for a conversion
217  return ((_Mode & (_STD consume_header | _STD generate_header)) != 0
218  ? 9 : 6);
219  }
Definition: codecvt:25
Definition: codecvt:24
_Check_return_ _In_z_ wchar_t const * _Mode
Definition: corecrt_wstdio.h:133
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
virtual result stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::do_out ( _Statype _State,
const _Elem *  _First1,
const _Elem *  _Last1,
const _Elem *&  _Mid1,
_Byte _First2,
_Byte _Last2,
_Byte *&  _Mid2 
) const
inlineprotectedvirtual
119  { // convert [_First1, _Last1) to bytes [_First2, _Last)
120  char *_Pstate = (char *)&_State;
121  _Mid1 = _First1;
122  _Mid2 = _First2;
123 
124  for (; _Mid1 != _Last1 && _Mid2 != _Last2; )
125  { // convert and put a wide char
126  _Byte _By;
127  int _Nextra;
128  unsigned long _Ch = (unsigned long)*_Mid1;
129 
130  if (_Maxcode < _Ch)
131  return (_Mybase::error);
132 
133  if (_Ch < 0x0080)
134  _By = (_Byte)_Ch, _Nextra = 0;
135  else if (_Ch < 0x0800)
136  _By = (_Byte)(0xc0 | _Ch >> 6), _Nextra = 1;
137  else if (_Ch < 0x00010000)
138  _By = (_Byte)(0xe0 | _Ch >> 12), _Nextra = 2;
139  else if (_Ch < 0x00200000)
140  _By = (_Byte)(0xf0 | _Ch >> 18), _Nextra = 3;
141  else if (_Ch < 0x04000000)
142  _By = (_Byte)(0xf8 | _Ch >> 24), _Nextra = 4;
143  else
144  _By = (_Byte)(0xfc | (_Ch >> 30 & 0x03)), _Nextra = 5;
145 
146  if (*_Pstate == 0)
147  { // first time, maybe generate header
148  *_Pstate = 1;
149  if ((_Mode & _STD generate_header) == 0)
150  ;
151  else if (_Last2 - _Mid2 < 3 + 1 + _Nextra)
152  return (_Mybase::partial); // not enough room for both
153  else
154  { // prepend header
155  *_Mid2++ = (_Byte)(unsigned char)0xef;
156  *_Mid2++ = (_Byte)(unsigned char)0xbb;
157  *_Mid2++ = (_Byte)(unsigned char)0xbf;
158  }
159  }
160 
161  if (_Last2 - _Mid2 < 1 + _Nextra)
162  break; // not enough room for output
163 
164  ++_Mid1;
165  for (*_Mid2++ = _By; 0 < _Nextra; )
166  *_Mid2++ = (_Byte)((_Ch >> 6 * --_Nextra & 0x3f) | 0x80);
167  }
168  return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
169  }
Definition: codecvt:25
char _Byte
Definition: utf8:34
_In_ long
Definition: corecrt_wstdlib.h:88
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
_In_ size_t _Deref_pre_opt_z_ char const _In_ size_t _Inout_ mbstate_t * _State
Definition: wchar.h:78
_Check_return_ _In_z_ wchar_t const * _Mode
Definition: corecrt_wstdio.h:133
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0>
virtual result stdext::cvt::codecvt_utf8< _Elem, _Maxcode, _Mode >::do_unshift ( _Statype ,
_Byte _First2,
_Byte ,
_Byte *&  _Mid2 
) const
inlineprotectedvirtual
173  { // generate bytes to return to default shift state
174  _Mid2 = _First2;
175  return (_Mybase::ok);
176  }

The documentation for this class was generated from the following file: