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_sjis_0208< _Elem, _Maxcode > Class Template Reference
Inheritance diagram for stdext::cvt::codecvt_sjis_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_sjis_0208 (size_t _Refs=0)
 
virtual ~codecvt_sjis_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_sjis_0208< _Elem, _Maxcode >::_Byte
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
typedef _STD codecvt<_Elem, char, _Statype> stdext::cvt::codecvt_sjis_0208< _Elem, _Maxcode >::_Mybase
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
typedef _Byte stdext::cvt::codecvt_sjis_0208< _Elem, _Maxcode >::extern_type
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
typedef _Elem stdext::cvt::codecvt_sjis_0208< _Elem, _Maxcode >::intern_type
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
typedef _Mybase::result stdext::cvt::codecvt_sjis_0208< _Elem, _Maxcode >::result
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
typedef _Statype stdext::cvt::codecvt_sjis_0208< _Elem, _Maxcode >::state_type

Constructor & Destructor Documentation

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

Member Function Documentation

template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual bool stdext::cvt::codecvt_sjis_0208< _Elem, _Maxcode >::do_always_noconv ( ) const
inlineprotectedvirtual
182  { // return true if conversions never change input
183  return (false);
184  }
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual int stdext::cvt::codecvt_sjis_0208< _Elem, _Maxcode >::do_encoding ( ) const
inlineprotectedvirtual
192  { // return length of code sequence (from codecvt)
193  return (0); // 0 => varying length
194  }
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual result stdext::cvt::codecvt_sjis_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  unsigned long _Maxc = _Maxcode; // to quiet warnings
49  static unsigned char _Xff = 0xff;
50 
51  _Mid1 = _First1;
52  _Mid2 = _First2;
53  for (; _Mid1 != _Last1 && _Mid2 != _Last2; )
54  { // convert a multibyte sequence
55  unsigned char _By = (unsigned char)*_Mid1;
56  unsigned short _Ch = _By;
57 
58  if (_By <= 0x80
59  || (0xa0 <= _By && _By <= 0xdf)
60  || (0xf0 <= _By && _By <= _Xff))
61  ;
62  else if (_Last1 - _Mid1 < 2)
63  break;
64  else
65  { // convert 2-byte code
66  unsigned char _By2 = *++_Mid1;
67 
68  if ((_By2 < 0x40 || 0x7e < _By2)
69  && (_By2 < 0x80 && 0xfc < _By2))
70  return (_Mybase::error); // bad second byte
71 
72  if (0xe0 <= _Ch)
73  _Ch -= 0xb0; // MS [e0, ef] => [30, 3f]
74  else
75  _Ch -= 0x70; // MS [81, 9f] => [11, 2f]
76  _Ch <<= 9; // MS [11, 3f] => [22, 7e] in place
77 
78  if (0x9f <= _By2)
79  _Ch = (unsigned short)(_Ch
80  + (_By2 - 0x7e)); // LS [9f, fc] => [21, 7e]
81  else if (_By2 <= 0x7e)
82  _Ch = (unsigned short)(_Ch
83  + (_By2 - 0x11f)); // LS [40, 7e] => [21, 5f] - 100
84  else
85  _Ch = (unsigned short)(_Ch
86  + (_By2 - 0x120)); // LS [80, 9e] => [60, 7e] - 100
87  }
88 
89  if (_Maxc < _Ch)
90  return (_Mybase::error); // code too large
91  ++_Mid1;
92  *_Mid2++ = (_Elem)_Ch;
93  }
94 
95  return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
96  }
_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_sjis_0208< _Elem, _Maxcode >::do_length ( _Statype _State,
const _Byte _First1,
const _Byte _Last1,
size_t  _Count 
) const
inlineprotectedvirtual
151  { // return min(_Count, converted length of bytes [_First1, _Last1))
152  size_t _Wchars = 0;
153  _Statype _Mystate = _State;
154 
155  for (; _Wchars < _Count && _First1 != _Last1; )
156  { // convert another wide character
157  const _Byte *_Mid1;
158  _Elem *_Mid2;
159  _Elem _Ch;
160 
161  switch (do_in(_Mystate, _First1, _Last1, _Mid1,
162  &_Ch, &_Ch + 1, _Mid2))
163  { // test result of single wide-char conversion
164  case _Mybase::noconv:
165  return ((int)(_Wchars + (_Last1 - _First1)));
166 
167  case _Mybase::ok:
168  if (_Mid2 == &_Ch + 1)
169  ++_Wchars; // replacement do_in might not convert one
170  _First1 = _Mid1;
171  break;
172 
173  default:
174  return ((int)_Wchars); // error or partial
175  }
176  }
177 
178  return ((int)_Wchars);
179  }
_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
virtual result do_in(_Statype &, const _Byte *_First1, const _Byte *_Last1, const _Byte *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
Definition: sjis_0208:44
_Diff _Count
Definition: algorithm:1941
char _Byte
Definition: sjis_0208:29
_CSTD mbstate_t _Statype
Definition: codecvt:28
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual int stdext::cvt::codecvt_sjis_0208< _Elem, _Maxcode >::do_max_length ( ) const
inlineprotectedvirtual
187  { // return maximum length required for a conversion
188  return (3);
189  }
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual result stdext::cvt::codecvt_sjis_0208< _Elem, _Maxcode >::do_out ( _Statype ,
const _Elem *  _First1,
const _Elem *  _Last1,
const _Elem *&  _Mid1,
_Byte _First2,
_Byte _Last2,
_Byte *&  _Mid2 
) const
inlineprotectedvirtual
101  { // convert [_First1, _Last1) to bytes [_First2, _Last)
102  unsigned long _Maxc = _Maxcode; // to quiet warnings
103 
104  _Mid1 = _First1;
105  _Mid2 = _First2;
106  for (; _Mid1 != _Last1 && _Mid2 != _Last2; )
107  { // convert and put a wide char
108  unsigned long _Ch = (unsigned long)*_Mid1;
109  static unsigned char _Xff = 0xff;
110 
111  if (_Maxc < _Ch)
112  return (_Mybase::error);
113 
114  if (_Ch <= 0x80
115  || (0xa0 <= _Ch && _Ch <= 0xdf)
116  || (0xf0 <= _Ch && _Ch <= _Xff))
117  *_Mid2++ = (_Byte)_Ch;
118  else if (_Last2 - _Mid2 < 2)
119  break;
120  else
121  { // convert 2-byte code
122  unsigned char _By0 = (unsigned char)(_Ch >> 8);
123  unsigned char _By1 = (unsigned char)_Ch;
124  if (_By0 < 0x21 || 0x7e < _By0
125  || _By1 < 0x21 || 0x7e < _By1)
126  return (_Mybase::error);
127 
128  *_Mid2++ = (_Byte)((_By0 + 1) / 2
129  + (_By0 < 0x5f ? 0x70 : 0xb0));
130  if ((_By0 & 1) != 0)
131  *_Mid2++ = (_Byte)(_By1 + (0x5f <= _By1 ? 0x20 : 0x1f));
132  else
133  *_Mid2++ = (_Byte)(_By1 + 0x7e);
134  }
135  ++_Mid1;
136  }
137 
138  return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
139  }
_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: sjis_0208:29
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual result stdext::cvt::codecvt_sjis_0208< _Elem, _Maxcode >::do_unshift ( _Statype ,
_Byte _First2,
_Byte ,
_Byte *&  _Mid2 
) const
inlineprotectedvirtual
143  { // generate bytes to return to default shift state
144  _Mid2 = _First2;
145 
146  return (_Mybase::ok);
147  }

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