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
37  : _Mybase(_Refs)
38  { // construct with ref count
39  }
_STD codecvt< _Elem, char, _Statype > _Mybase
Definition: sjis_0208:29
template<class _Elem , unsigned long _Maxcode = 0x7e7e>
virtual stdext::cvt::codecvt_sjis_0208< _Elem, _Maxcode >::~codecvt_sjis_0208 ( )
inlinevirtual
42  { // destroy the object
43  }

Member Function Documentation

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

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