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
35  : _Mybase(_Refs)
36  { // construct with ref count
37  }
_STD codecvt< _Elem, char, _Statype > _Mybase
Definition: euc_0208:27
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual stdext::cvt::codecvt_euc_0208< _Elem, _Maxcode >::~codecvt_euc_0208 ( )
inlinevirtual
40  { // destroy the object
41  }

Member Function Documentation

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

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