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_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word > Class Template Reference
Inheritance diagram for stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >:

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_one_one (size_t _Refs=0)
 
virtual ~codecvt_one_one () _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, size_t _Bytes_per_word = sizeof (_Elem)>
typedef char stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::_Byte
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0, size_t _Bytes_per_word = sizeof (_Elem)>
typedef _STD codecvt<_Elem, char, _Statype> stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::_Mybase
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0, size_t _Bytes_per_word = sizeof (_Elem)>
typedef _Byte stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::extern_type
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0, size_t _Bytes_per_word = sizeof (_Elem)>
typedef _Elem stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::intern_type
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0, size_t _Bytes_per_word = sizeof (_Elem)>
typedef _Mybase::result stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::result
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0, size_t _Bytes_per_word = sizeof (_Elem)>
typedef _Statype stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::state_type

Constructor & Destructor Documentation

template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0, size_t _Bytes_per_word = sizeof (_Elem)>
stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::codecvt_one_one ( size_t  _Refs = 0)
inlineexplicit
44  : _Mybase(_Refs)
45  { // construct with ref count
46  }
_STD codecvt< _Elem, char, _Statype > _Mybase
Definition: one_one:34
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0, size_t _Bytes_per_word = sizeof (_Elem)>
virtual stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::~codecvt_one_one ( )
inlinevirtual
49  { // destroy the object
50  }

Member Function Documentation

template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0, size_t _Bytes_per_word = sizeof (_Elem)>
virtual bool stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::do_always_noconv ( ) const
inlineprotectedvirtual
215  { // return true if conversions never change input
216  return (false);
217  }
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0, size_t _Bytes_per_word = sizeof (_Elem)>
virtual int stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::do_encoding ( ) const
inlineprotectedvirtual
226  { // return length of code sequence (from codecvt)
227  return ((_Mode & (_STD consume_header | _STD generate_header)) != 0
228  ? -1 : (int)_Bytes_per_word); // -1 => state dependent
229  }
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, size_t _Bytes_per_word = sizeof (_Elem)>
virtual result stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::do_in ( _Statype _State,
const _Byte _First1,
const _Byte _Last1,
const _Byte *&  _Mid1,
_Elem *  _First2,
_Elem *  _Last2,
_Elem *&  _Mid2 
) const
inlineprotectedvirtual
56  { // convert bytes [_First1, _Last1) to [_First2, _Last)
57  char *_Pstate = (char *)&_State;
58  size_t _Count;
59  _Mid1 = _First1;
60  _Mid2 = _First2;
61 
62  for (; _Bytes_per_word <= _Last1 - _Mid1 && _Mid2 != _Last2; )
63  { // convert a multibyte sequence
64  unsigned char *_Ptr = (unsigned char *)_Mid1;
65  unsigned long _Ch = 0;
66 
67  if (*_Pstate == _LITTLE_FIRST)
68  for (_Count = _Bytes_per_word; 0 < _Count; )
69  _Ch = _Ch << 8 | _Ptr[--_Count];
70  else if (*_Pstate == _BIG_FIRST)
71  for (_Count = 0; _Count < _Bytes_per_word; ++_Count)
72  _Ch = _Ch << 8 | _Ptr[_Count];
73  else
74  { // no header seen yet, try preferred mode
75  unsigned char _Default_endian =
76  (_Mode & _STD little_endian) != 0
78 
79  if ((_Mode & _STD little_endian) != 0)
80  for (_Count = _Bytes_per_word; 0 < _Count; )
81  _Ch = _Ch << 8 | _Ptr[--_Count];
82  else
83  for (_Count = 0; _Count < _Bytes_per_word; ++_Count)
84  _Ch = _Ch << 8 | _Ptr[_Count];
85  if ((_Mode & _STD consume_header) == 0
86  || (_Ch != 0xfeff
87  && _Ch != (0xfffe0000 >> 8 * (4 - _Bytes_per_word))))
88  *_Pstate = _Default_endian;
89  else
90  { // consume header, fixate on endianness, and retry
91  _Mid1 += _Bytes_per_word;
92  *_Pstate = (char)(_Ch == 0xfeff
93  ? _Default_endian
94  : (unsigned char)(3 - _Default_endian));
95  result _Ans = do_in(_State, _Mid1, _Last1, _Mid1,
96  _First2, _Last2, _Mid2);
97 
98  if (_Ans == _Mybase::partial)
99  { // not enough bytes, roll back header
100  *_Pstate = 0;
101  _Mid1 = _First1;
102  }
103  return (_Ans);
104  }
105  }
106 
107  _Mid1 += _Bytes_per_word;
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  }
virtual result do_in(_Statype &_State, const _Byte *_First1, const _Byte *_Last1, const _Byte *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
Definition: one_one:53
Definition: codecvt:26
Definition: codecvt:24
#define _BIG_FIRST
Definition: codecvt:20
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
_Mybase::result result
Definition: one_one:37
_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
_Diff _Count
Definition: algorithm:1941
#define _LITTLE_FIRST
Definition: codecvt:19
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0, size_t _Bytes_per_word = sizeof (_Elem)>
virtual int stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::do_length ( _Statype _State,
const _Byte _First1,
const _Byte _Last1,
size_t  _Count 
) const
inlineprotectedvirtual
184  { // return min(_Count, converted length of bytes [_First1, _Last1))
185  size_t _Wchars = 0;
186  _Statype _Mystate = _State;
187 
188  for (; _Wchars < _Count && _First1 != _Last1; )
189  { // convert another wide character
190  const _Byte *_Mid1;
191  _Elem *_Mid2;
192  _Elem _Ch;
193 
194  switch (do_in(_Mystate, _First1, _Last1, _Mid1,
195  &_Ch, &_Ch + 1, _Mid2))
196  { // test result of single wide-char conversion
197  case _Mybase::noconv:
198  return ((int)(_Wchars + (_Last1 - _First1)));
199 
200  case _Mybase::ok:
201  if (_Mid2 == &_Ch + 1)
202  ++_Wchars; // replacement do_in might not convert one
203  _First1 = _Mid1;
204  break;
205 
206  default:
207  return ((int)_Wchars); // error or partial
208  }
209  }
210 
211  return ((int)_Wchars);
212  }
char _Byte
Definition: one_one:38
virtual result do_in(_Statype &_State, const _Byte *_First1, const _Byte *_Last1, const _Byte *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
Definition: one_one:53
_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
_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, size_t _Bytes_per_word = sizeof (_Elem)>
virtual int stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::do_max_length ( ) const
inlineprotectedvirtual
220  { // return maximum length required for a conversion
221  return ((_Mode & (_STD consume_header | _STD generate_header)) != 0
222  ? 2 * _Bytes_per_word : _Bytes_per_word);
223  }
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, size_t _Bytes_per_word = sizeof (_Elem)>
virtual result stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::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  size_t _Count;
122  _Mid1 = _First1;
123  _Mid2 = _First2;
124 
125  if (*_Pstate == 0)
126  { // determine endianness once, maybe generate header
127  unsigned long _Header = 0xfeff;
128 
129  *_Pstate = (_Mode & _STD little_endian) != 0
131  if ((_Mode & _STD generate_header) == 0)
132  ;
133  else if (_Last2 - _Mid2 < 2 * _Bytes_per_word)
134  return (_Mybase::partial); // not enough room for both
135  else if (*_Pstate == _LITTLE_FIRST)
136  for (_Count = 0; _Count < _Bytes_per_word; ++_Count)
137  { // put LS byte first
138  *_Mid2++ = (unsigned char)_Header;
139  _Header >>= 8;
140  }
141  else
142  for (_Header <<= 8 * (4 - _Bytes_per_word), _Count = 0;
143  _Count < _Bytes_per_word; ++_Count)
144  { // put MS byte first
145  *_Mid2++ = (unsigned char)(_Header >> 24);
146  _Header <<= 8;
147  }
148  }
149 
150  for (; _Mid1 != _Last1 && _Bytes_per_word <= _Last2 - _Mid2; )
151  { // convert and put a wide char
152  unsigned long _Ch = (unsigned long)*_Mid1++;
153 
154  if (_Maxcode < _Ch)
155  return (_Mybase::error);
156 
157  if (*_Pstate == _LITTLE_FIRST)
158  for (_Count = 0; _Count < _Bytes_per_word; ++_Count)
159  { // put LS byte first
160  *_Mid2++ = (unsigned char)_Ch;
161  _Ch >>= 8;
162  }
163  else
164  for (_Ch <<= 8 * (4 - _Bytes_per_word), _Count = 0;
165  _Count < _Bytes_per_word; ++_Count)
166  { // put MS byte first
167  *_Mid2++ = (unsigned char)(_Ch >> 24);
168  _Ch <<= 8;
169  }
170  }
171 
172  return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
173  }
Definition: codecvt:25
_In_ long
Definition: corecrt_wstdlib.h:88
Definition: codecvt:26
#define _BIG_FIRST
Definition: codecvt:20
_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
_Diff _Count
Definition: algorithm:1941
#define _LITTLE_FIRST
Definition: codecvt:19
template<class _Elem , unsigned long _Maxcode = 0xffffffff, _STD codecvt_mode _Mode = (_STD codecvt_mode)0, size_t _Bytes_per_word = sizeof (_Elem)>
virtual result stdext::cvt::codecvt_one_one< _Elem, _Maxcode, _Mode, _Bytes_per_word >::do_unshift ( _Statype ,
_Byte _First2,
_Byte ,
_Byte *&  _Mid2 
) const
inlineprotectedvirtual
177  { // generate bytes to return to default shift state
178  _Mid2 = _First2;
179  return (_Mybase::ok);
180  }

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