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

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

Constructor & Destructor Documentation

template<class _Elem , unsigned long _Maxcode = 0x7e7e>
stdext::cvt::codecvt_euc_0208< _Elem, _Maxcode >::codecvt_euc_0208 ( size_t  _Refs = 0)
inlineexplicit
36  : _Mybase(_Refs)
37  { // construct with ref count
38  }
_STD codecvt< _Elem, char, _Statype > _Mybase
Definition: euc_0208:28
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual stdext::cvt::codecvt_euc_0208< _Elem, _Maxcode >::~codecvt_euc_0208 ( )
inlinevirtual
41  { // destroy the object
42  }

Member Function Documentation

template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual bool stdext::cvt::codecvt_euc_0208< _Elem, _Maxcode >::do_always_noconv ( ) const
inlineprotectedvirtual
171  { // return true if conversions never change input
172  return (false);
173  }
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual int stdext::cvt::codecvt_euc_0208< _Elem, _Maxcode >::do_encoding ( ) const
inlineprotectedvirtual
181  { // return length of code sequence (from codecvt)
182  return (0); // 0 => varying length
183  }
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual result stdext::cvt::codecvt_euc_0208< _Elem, _Maxcode >::do_in ( _Statype ,
const _Byte _First1,
const _Byte _Last1,
const _Byte *&  _Mid1,
_Elem *  _First2,
_Elem *  _Last2,
_Elem *&  _Mid2 
) const
inlineprotectedvirtual
48  { // convert bytes [_First1, _Last1) to [_First2, _Last)
49  _Mid1 = _First1;
50  _Mid2 = _First2;
51 
52  for (; _Mid1 != _Last1 && _Mid2 != _Last2; )
53  { // convert a multibyte sequence
54  unsigned char _By = (unsigned char)*_Mid1;
55  unsigned short _Ch;
56  bool _Extra;
57 
58  if (_By == 0x8e)
59  _Ch = 0, _Extra = true;
60  else if (0xa1 <= _By && _By <= 0xfe)
61  _Ch = (unsigned short)((_By << 8) - 0x8080), _Extra = true;
62  else
63  _Ch = _By, _Extra = false;
64 
65  if (!_Extra)
66  ;
67  else if (_Last1 - _Mid1 < 2)
68  break;
69  else if ((_By = (unsigned char)*++_Mid1) < 0xa1 || 0xfe < _By)
70  return (_Mybase::error); // bad second byte
71  else
72  _Ch = (unsigned short)(_Ch + _By);
73 
74  if (_Maxcode < _Ch)
75  return (_Mybase::error); // code too large
76  ++_Mid1;
77  *_Mid2++ = (_Elem)_Ch;
78  }
79 
80  return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
81  }
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
unsigned char
Definition: mbstring.h:107
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual int stdext::cvt::codecvt_euc_0208< _Elem, _Maxcode >::do_length ( _Statype _State,
const _Byte _First1,
const _Byte _Last1,
size_t  _Count 
) const
inlineprotectedvirtual
140  { // return min(_Count, converted length of bytes [_First1, _Last1))
141  size_t _Wchars = 0;
142  _Statype _Mystate = _State;
143 
144  for (; _Wchars < _Count && _First1 != _Last1; )
145  { // convert another wide character
146  const _Byte *_Mid1;
147  _Elem *_Mid2;
148  _Elem _Ch;
149 
150  switch (do_in(_Mystate, _First1, _Last1, _Mid1,
151  &_Ch, &_Ch + 1, _Mid2))
152  { // test result of single wide-char conversion
153  case _Mybase::noconv:
154  return ((int)(_Wchars + (_Last1 - _First1)));
155 
156  case _Mybase::ok:
157  if (_Mid2 == &_Ch + 1)
158  ++_Wchars; // replacement do_in might not convert one
159  _First1 = _Mid1;
160  break;
161 
162  default:
163  return ((int)_Wchars); // error or partial
164  }
165  }
166 
167  return ((int)_Wchars);
168  }
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
virtual result do_in(_Statype &, const _Byte *_First1, const _Byte *_Last1, const _Byte *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
Definition: euc_0208:45
_In_ size_t _Deref_pre_opt_z_ char const _In_ size_t _Inout_ mbstate_t * _State
Definition: wchar.h:78
char _Byte
Definition: euc_0208:30
_Diff _Count
Definition: algorithm:1941
_CSTD mbstate_t _Statype
Definition: codecvt:28
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual int stdext::cvt::codecvt_euc_0208< _Elem, _Maxcode >::do_max_length ( ) const
inlineprotectedvirtual
176  { // return maximum length required for a conversion
177  return (3);
178  }
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual result stdext::cvt::codecvt_euc_0208< _Elem, _Maxcode >::do_out ( _Statype ,
const _Elem *  _First1,
const _Elem *  _Last1,
const _Elem *&  _Mid1,
_Byte _First2,
_Byte _Last2,
_Byte *&  _Mid2 
) const
inlineprotectedvirtual
86  { // convert [_First1, _Last1) to bytes [_First2, _Last)
87  _Mid1 = _First1;
88  _Mid2 = _First2;
89 
90  for (; _Mid1 != _Last1 && _Mid2 != _Last2; )
91  { // convert and put a wide char
92  unsigned long _Ch = (unsigned long)*_Mid1;
93 
94  if (_Maxcode < _Ch)
95  return (_Mybase::error);
96 
97  if (0xa1 <= _Ch && _Ch <= 0xfe)
98  if (_Last2 - _Mid2 < 2)
99  break;
100  else
101  { // put 0x8e plus 1-byte code
102  *_Mid2++ = (_Byte)(unsigned short)0x8e;
103  *_Mid2++ = (_Byte)_Ch;
104  }
105  else if (_Ch == 0x8e)
106  return (_Mybase::error);
107  else if (_Ch <= 0xff)
108  *_Mid2++ = (_Byte)_Ch;
109  else
110  if (_Last2 - _Mid2 < 2)
111  break;
112  else
113  { // put 2-byte code
114  unsigned char _By = (unsigned char)((_Ch >> 8) + 0x80);
115 
116  if (_By < 0xa1 || 0xfe < _By)
117  return (_Mybase::error); // bad first byte
118  *_Mid2++ = (_Byte)_By;
119 
120  _By = (unsigned char)(_Ch + 0x80);
121  if (_By < 0xa1 || 0xfe < _By)
122  return (_Mybase::error); // bad second byte
123  *_Mid2++ = (_Byte)_By;
124  }
125  ++_Mid1;
126  }
127  return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
128  }
_In_ long
Definition: corecrt_wstdlib.h:88
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
unsigned char
Definition: mbstring.h:107
char _Byte
Definition: euc_0208:30
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual result stdext::cvt::codecvt_euc_0208< _Elem, _Maxcode >::do_unshift ( _Statype ,
_Byte _First2,
_Byte ,
_Byte *&  _Mid2 
) const
inlineprotectedvirtual
132  { // generate bytes to return to default shift state
133  _Mid2 = _First2;
134 
135  return (_Mybase::ok);
136  }

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