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
38  : _Mybase(_Refs)
39  { // construct with ref count
40  }
_STD codecvt< _Elem, char, _Statype > _Mybase
Definition: xtwo_byte:30
template<class _Elem, class _Table, unsigned long _Maxcode = 0xffff>
virtual stdext::cvt::_Cvt_two_byte< _Elem, _Table, _Maxcode >::~_Cvt_two_byte ( )
inlinevirtual
43  { // destroy the object
44  }

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

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