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::_Cvt_two_byte< _Elem, _Table, _Maxcode > Class Template Reference
Inheritance diagram for stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >:

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

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

Protected Member Functions

virtual result do_in (_Statype &, const _Byte *_First1, const _Byte *_Last1, const _Byte *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
 
virtual result do_out (_Statype &, 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, class _Table, unsigned long _Maxcode = 0xffff>
typedef char stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >::_Byte
template<class _Elem, class _Table, unsigned long _Maxcode = 0xffff>
typedef _STD codecvt<_Elem, char, _Statype> stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >::_Mybase
template<class _Elem, class _Table, unsigned long _Maxcode = 0xffff>
typedef _Byte stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >::extern_type
template<class _Elem, class _Table, unsigned long _Maxcode = 0xffff>
typedef _Elem stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >::intern_type
template<class _Elem, class _Table, unsigned long _Maxcode = 0xffff>
typedef _Mybase::result stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >::result
template<class _Elem, class _Table, unsigned long _Maxcode = 0xffff>
typedef _Statype stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >::state_type

Constructor & Destructor Documentation

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

Member Function Documentation

template<class _Elem, class _Table, unsigned long _Maxcode = 0xffff>
virtual bool stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >::do_always_noconv ( ) const
inlineprotectedvirtual
197  { // return true if conversions never change input
198  return (false);
199  }
template<class _Elem, class _Table, unsigned long _Maxcode = 0xffff>
virtual int stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >::do_encoding ( ) const
inlineprotectedvirtual
207  { // return length of code sequence (from codecvt)
208  return (0); // 0 => varying length
209  }
template<class _Elem, class _Table, unsigned long _Maxcode = 0xffff>
virtual result stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >::do_in ( _Statype ,
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  unsigned long _Maxc = _Maxcode; // to quiet warnings
54 
55  _Mid1 = _First1;
56  _Mid2 = _First2;
57  for (; _Mid1 != _Last1 && _Mid2 != _Last2; ++_Mid1)
58  { // get a byte and map it
59  unsigned char _Bytecode = (unsigned char)*_Mid1;
60  unsigned short _Widecode;
61 
62  if (_Bytecode < _Table::_Nlow)
63  _Widecode = _Bytecode; // map byte to same wide value
64  else if ((_Widecode =
65  _Table::_Btw[_Bytecode - _Table::_Nlow]) != 0)
66  ; // map byte to wide value
67  else if (_Table::_Nbytes < 2)
68  return (_Mybase::error); // no single-byte mapping
69  else if (_Mid1 + 1 == _Last1)
70  break; // need another input byte
71  else
72  { // form double-byte code and search for a valid mapping
73  _Widecode = (unsigned short)(_Bytecode << 8
74  | (unsigned char)*++_Mid1);
75  unsigned long _Lo = 0;
76  unsigned long _Hi = sizeof (_Table::_Dbvalid)
77  / sizeof (_Table::_Dbvalid[0]);
78 
79  for (; _Lo < _Hi; )
80  { // test midpoint of remaining interval
81  unsigned long _Mid = (_Hi + _Lo) / 2;
82 
83  if (_Widecode < _Table::_Dbvalid[_Mid])
84  _Hi = _Mid;
85  else if (_Widecode == _Table::_Dbvalid[_Mid])
86  { // found the code, map it
87  _Widecode = _Table::_Dbtw[_Mid];
88  break;
89  }
90  else
91  _Lo = _Mid + 1;
92  }
93  if (_Hi <= _Lo)
94  return (_Mybase::error);
95  }
96  if (_Maxc < _Widecode)
97  return (_Mybase::error); // value too large
98  else
99  *_Mid2++ = (_Elem)_Widecode;
100  }
101 
102  return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
103  }
unsigned char
Definition: mbstring.h:107
template<class _Elem, class _Table, unsigned long _Maxcode = 0xffff>
virtual int stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >::do_length ( _Statype _State,
const _Byte _First1,
const _Byte _Last1,
size_t  _Count 
) const
inlineprotectedvirtual
167  { // return min(_Count, converted length of bytes [_First1, _Last1))
168  size_t _Wchars = 0;
169  _Statype _Mystate = _State;
170 
171  for (; _Wchars < _Count && _First1 != _Last1; )
172  { // convert another wide character
173  const _Byte *_Mid1;
174  _Elem *_Mid2;
175  _Elem _Ch;
176 
177  switch (do_in(_Mystate, _First1, _Last1, _Mid1,
178  &_Ch, &_Ch + 1, _Mid2))
179  { // test result of single wide-char conversion
180  case _Mybase::noconv:
181  return ((int)(_Wchars + (_Last1 - _First1)));
182 
183  case _Mybase::ok:
184  if (_Mid2 == &_Ch + 1)
185  ++_Wchars; // replacement do_in might not convert one
186  _First1 = _Mid1;
187  break;
188 
189  default:
190  return ((int)_Wchars); // error or partial
191  }
192  }
193  return ((int)_Wchars);
194  }
_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
char _Byte
Definition: xtwo_byte:34
virtual result do_in(_Statype &, const _Byte *_First1, const _Byte *_Last1, const _Byte *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
Definition: xtwo_byte:49
_Diff _Count
Definition: algorithm:1941
_CSTD mbstate_t _Statype
Definition: codecvt:28
template<class _Elem, class _Table, unsigned long _Maxcode = 0xffff>
virtual int stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >::do_max_length ( ) const
inlineprotectedvirtual
202  { // return maximum length required for a conversion
203  return (_Table::_Nbytes); // length of sequence
204  }
template<class _Elem, class _Table, unsigned long _Maxcode = 0xffff>
virtual result stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >::do_out ( _Statype ,
const _Elem *  _First1,
const _Elem *  _Last1,
const _Elem *&  _Mid1,
_Byte _First2,
_Byte _Last2,
_Byte *&  _Mid2 
) const
inlineprotectedvirtual
108  { // convert [_First1, _Last1) to bytes [_First2, _Last)
109  unsigned long _Maxc = _Maxcode; // to quiet warnings
110 
111  _Mid1 = _First1;
112  _Mid2 = _First2;
113  for (; _Mid1 != _Last1 && _Mid2 != _Last2; ++_Mid1)
114  { // get an element and map it
115  unsigned long _Hugecode = (unsigned long)*_Mid1;
116  unsigned short _Widecode = (unsigned short)_Hugecode;
117 
118  if (_Maxc < _Widecode)
119  return (_Mybase::error); // value too large
120  else if (_Widecode < _Table::_Nlow || (_Widecode < 0x100
121  && _Table::_Btw[_Widecode - _Table::_Nlow] == _Widecode))
122  ; // map wide to same byte value
123  else
124  { // search for a valid mapping
125  unsigned long _Lo = 0;
126  unsigned long _Hi = sizeof (_Table::_Wvalid)
127  / sizeof (_Table::_Wvalid[0]);
128 
129  for (; _Lo < _Hi; )
130  { // test midpoint of remaining interval
131  unsigned long _Mid = (_Hi + _Lo) / 2;
132 
133  if (_Widecode < _Table::_Wvalid[_Mid])
134  _Hi = _Mid;
135  else if (_Widecode == _Table::_Wvalid[_Mid])
136  { // found the code, map it
137  _Widecode = _Table::_Wtb[_Mid];
138  break;
139  }
140  else
141  _Lo = _Mid + 1;
142  }
143  if (_Hi <= _Lo)
144  return (_Mybase::error);
145  }
146  if (_Widecode < 0x100)
147  ;
148  else if (_Mid2 + 1 == _Last2)
149  return (_Mybase::partial); // need room for another byte
150  else
151  *_Mid2++ = (_Byte)(_Widecode >> 8); // put ms byte
152  *_Mid2++ = (_Byte)_Widecode;
153  }
154 
155  return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
156  }
_In_ long
Definition: corecrt_wstdlib.h:88
char _Byte
Definition: xtwo_byte:34
template<class _Elem, class _Table, unsigned long _Maxcode = 0xffff>
virtual result stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >::do_unshift ( _Statype ,
_Byte _First2,
_Byte ,
_Byte *&  _Mid2 
) const
inlineprotectedvirtual
160  { // generate bytes to return to default shift state
161  _Mid2 = _First2;
162  return (_Mybase::ok);
163  }

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