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

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