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
41  : _Mybase(_Refs)
42  { // construct with ref count
43  if (_Bytes_per_word < 1 || 4 < _Bytes_per_word)
44  _THROW(_STD range_error, "bad byte count parameter");
45  }
Definition: stdexcept:239
#define _THROW(x, y)
Definition: xstddef:77
_STD codecvt< _Elem, char, _Statype > _Mybase
Definition: one_one:33
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
48  { // destroy the object
49  }

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

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