STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits > Class Template Reference
Inheritance diagram for stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >:

Public Types

typedef wbuffer_convert< _Codecvt, _Elem, _Traits > _Myt
 
typedef _STD streambuf _Mysb
 
typedef _STD char_traits< char > _Byte_traits
 
typedef _Traits::int_type int_type
 
typedef _Traits::pos_type pos_type
 
typedef _Traits::off_type off_type
 
typedef _Traits::state_type state_type
 

Public Member Functions

 wbuffer_convert (_Mysb *_Strbuf=0)
 
 wbuffer_convert (_Mysb *_Strbuf, _Codecvt *_Pcvt_arg)
 
 wbuffer_convert (_Mysb *_Strbuf, _Codecvt *_Pcvt_arg, state_type _State_arg)
 
virtual ~wbuffer_convert () _NOEXCEPT
 
_Mysbrdbuf () const
 
_Mysbrdbuf (_Mysb *_Strbuf)
 
state_type state () const
 
 wbuffer_convert (const _Myt &)=delete
 
_Mytoperator= (const _Myt &)=delete
 

Protected Member Functions

virtual int_type overflow (int_type _Meta=_Traits::eof())
 
virtual int_type pbackfail (int_type _Meta=_Traits::eof())
 
virtual int_type underflow ()
 
virtual int_type uflow ()
 
virtual pos_type seekoff (off_type, _STD ios::seekdir, _STD ios::openmode=(_STD ios::openmode)(_STD ios::in|_STD ios::out))
 
virtual pos_type seekpos (pos_type, _STD ios::openmode=(_STD ios::openmode)(_STD ios::in|_STD ios::out))
 

Private Types

enum  _Mode {
  _Unused, _Wrote, _Need, _Got,
  _Eof
}
 
enum  { _STRING_INC = 8 }
 

Private Member Functions

int_type _Get_elem ()
 

Private Attributes

state_type _State
 
_Codecvt * _Pcvt
 
_Mysb_Mystrbuf
 
_Mode _Status
 
size_t _Nback
 
_Elem _Myback [8]
 
_STD string _Str
 
_STD locale _Loc
 

Member Typedef Documentation

template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
typedef _STD char_traits<char> stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::_Byte_traits
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
typedef _STD streambuf stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::_Mysb
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
typedef wbuffer_convert<_Codecvt, _Elem, _Traits> stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::_Myt
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
typedef _Traits::int_type stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::int_type
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
typedef _Traits::off_type stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::off_type
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
typedef _Traits::pos_type stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::pos_type
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
typedef _Traits::state_type stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::state_type

Member Enumeration Documentation

template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
anonymous enum
private
Enumerator
_STRING_INC 
34 {_STRING_INC = 8};
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
enum stdext::cvt::wbuffer_convert::_Mode
private
Enumerator
_Unused 
_Wrote 
_Need 
_Got 
_Eof 

Constructor & Destructor Documentation

template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::wbuffer_convert ( _Mysb _Strbuf = 0)
inlineexplicit
47  : _Pcvt(new _Codecvt),
48  _Mystrbuf(_Strbuf), _Status(_Unused), _Nback(0)
49  { // construct with byte stream buffer pointer
50  static state_type _State0;
51 
52  _State = _State0;
54  }
_Mode _Status
Definition: wbuffer:315
state_type _State
Definition: wbuffer:312
size_t _Nback
Definition: wbuffer:316
_Mysb * _Mystrbuf
Definition: wbuffer:314
_Traits::state_type state_type
Definition: wbuffer:44
#define _ADDFAC(loc, pfac)
Definition: xlocale:545
_STD locale _Loc
Definition: wbuffer:319
_Codecvt * _Pcvt
Definition: wbuffer:313
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::wbuffer_convert ( _Mysb _Strbuf,
_Codecvt *  _Pcvt_arg 
)
inline
57  : _Pcvt(_Pcvt_arg),
58  _Mystrbuf(_Strbuf), _Status(_Unused), _Nback(0)
59  { // construct with byte stream buffer pointer and codecvt
60  static state_type _State0;
61 
62  _State = _State0;
64  }
_Mode _Status
Definition: wbuffer:315
state_type _State
Definition: wbuffer:312
size_t _Nback
Definition: wbuffer:316
_Mysb * _Mystrbuf
Definition: wbuffer:314
_Traits::state_type state_type
Definition: wbuffer:44
#define _ADDFAC(loc, pfac)
Definition: xlocale:545
_STD locale _Loc
Definition: wbuffer:319
_Codecvt * _Pcvt
Definition: wbuffer:313
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::wbuffer_convert ( _Mysb _Strbuf,
_Codecvt *  _Pcvt_arg,
state_type  _State_arg 
)
inline
68  : _Pcvt(_Pcvt_arg),
69  _Mystrbuf(_Strbuf), _Status(_Unused), _Nback(0)
70  { // construct with byte stream buffer pointer, codecvt, and state
71  _State = _State_arg;
73  }
_Mode _Status
Definition: wbuffer:315
state_type _State
Definition: wbuffer:312
size_t _Nback
Definition: wbuffer:316
_Mysb * _Mystrbuf
Definition: wbuffer:314
#define _ADDFAC(loc, pfac)
Definition: xlocale:545
_STD locale _Loc
Definition: wbuffer:319
_Codecvt * _Pcvt
Definition: wbuffer:313
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
virtual stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::~wbuffer_convert ( )
inlinevirtual
76  { // destroy the object
77  char *_Buf = (char *)_Str.c_str();
78 
79  for (; _Status == _Wrote ; )
80  { // put any trailing homing shift
81  char *_Dest;
82 
83  if (_Str.size() < _STRING_INC)
84  _Str.assign(_STRING_INC, '\0');
85  switch (_Pcvt->unshift(_State,
86  _Buf, _Buf + _Str.size(), _Dest))
87  { // test result of homing conversion
88  case _Codecvt::ok:
89  _Status = _Unused; // homed successfully
90 
91  case _Codecvt::partial: // fall through
92  { // put any generated bytes
93  size_t _Count = _Dest - _Buf;
94  if (0 < _Count
95  && _Byte_traits::eq_int_type(
96  _Byte_traits::eof(),
97  (typename _Traits::int_type)_Mystrbuf->sputn(
98  _Buf,
99  (_STD streamsize)_Count)))
100  return; // write failed
101 
102  if (_Status == _Wrote && _Count == 0)
103  _Str.append(_STRING_INC, '\0'); // try with more space
104  break;
105  }
106 
107  case _Codecvt::noconv:
108  return; // nothing to do
109 
110  default:
111  return; // conversion failed
112  }
113  }
114 
115  }
_Mode _Status
Definition: wbuffer:315
_Longlong streamsize
Definition: iosfwd:22
unsigned int _Count
Definition: xcomplex:668
state_type _State
Definition: wbuffer:312
Definition: regex:1539
_Mysb * _Mystrbuf
Definition: wbuffer:314
const _Elem * c_str() const _NOEXCEPT
Definition: xstring:1741
_STD string _Str
Definition: wbuffer:318
_Myt & assign(_Myt &&_Right) _NOEXCEPT
Definition: xstring:945
size_type size() const _NOEXCEPT
Definition: xstring:1763
_Myt & append(_XSTD initializer_list< _Elem > _Ilist)
Definition: xstring:998
_Codecvt * _Pcvt
Definition: wbuffer:313
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::wbuffer_convert ( const _Myt )
delete

Member Function Documentation

template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
int_type stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::_Get_elem ( )
inlineprivate
258  { // compose an element from byte stream buffer
259  if (_Mystrbuf != 0 && _Status != _Wrote)
260  { // got buffer, haven't written, try to compose an element
261  if (_Status == _Eof)
262  ;
263  else if (_Str.size() == 0)
264  _Status = _Need;
265  else
266  _Status = _Got;
267 
268  for (; _Status != _Eof; )
269  { // get using codecvt facet
270  char *_Buf = (char *)_Str.c_str();
271  _Elem _Ch, *_Dest;
272  const char *_Src;
273  int _Meta;
274 
275  if (_Status != _Need)
276  ;
277  else if (_Byte_traits::eq_int_type(_Byte_traits::eof(),
278  _Meta = _Mystrbuf->sbumpc()))
279  _Status = _Eof;
280  else
281  _Str.append(1, _Byte_traits::to_char_type(_Meta));
282 
283  switch (_Pcvt->in(_State,
284  _Buf, _Buf + _Str.size(), _Src,
285  &_Ch, &_Ch + 1, _Dest))
286  { // test result of converting one element
287  case _Codecvt::partial:
288  case _Codecvt::ok:
289  _Str.erase((size_t)0, // discard any used input
290  (size_t)(_Src - _Buf));
291  if (_Dest != &_Ch)
292  return (_Traits::to_int_type(_Ch));
293  break;
294 
295  case _Codecvt::noconv:
296  if (_Str.size() < sizeof (_Elem))
297  break; // no conversion, but need more chars
298  _CSTD memcpy(&_Ch, _Buf,
299  sizeof (_Elem)); // copy raw bytes to element
300  _Str.erase((size_t)0, sizeof (_Elem));
301  return (_Traits::to_int_type(_Ch)); // return result
302 
303  default:
304  _Status = _Eof; // conversion failed
305  }
306  }
307  }
308 
309  return (_Traits::eof());
310  }
_Mode _Status
Definition: wbuffer:315
state_type _State
Definition: wbuffer:312
Definition: regex:1539
_Mysb * _Mystrbuf
Definition: wbuffer:314
const _Elem * c_str() const _NOEXCEPT
Definition: xstring:1741
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
_STD string _Str
Definition: wbuffer:318
_Myt & erase(size_type _Off=0)
Definition: xstring:1339
size_type size() const _NOEXCEPT
Definition: xstring:1763
#define _CSTD
Definition: yvals.h:570
_Myt & append(_XSTD initializer_list< _Elem > _Ilist)
Definition: xstring:998
_Codecvt * _Pcvt
Definition: wbuffer:313
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
_Myt& stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::operator= ( const _Myt )
delete
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
virtual int_type stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::overflow ( int_type  _Meta = _Traits::eof())
inlineprotectedvirtual
139  { // put an element to stream
140  if (_Traits::eq_int_type(_Traits::eof(), _Meta))
141  return (_Traits::not_eof(_Meta)); // EOF, return success code
142  else if (_Mystrbuf == 0 || 0 < _Nback
143  || (_Status != _Unused && _Status != _Wrote))
144  return (_Traits::eof()); // no buffer or reading, fail
145  else
146  { // put using codecvt facet
147  char *_Buf = (char *)_Str.c_str();
148  const _Elem _Ch = _Traits::to_char_type(_Meta);
149  const _Elem *_Src;
150  char *_Dest;
151 
152  if (_Str.size() < _STRING_INC)
153  _Str.assign(_STRING_INC, '\0');
154  for (_Status = _Wrote; ; )
155  switch (_Pcvt->out(_State,
156  &_Ch, &_Ch + 1, _Src,
157  _Buf, _Buf + _Str.size(), _Dest))
158  { // test result of converting one element
159  case _Codecvt::partial:
160  case _Codecvt::ok:
161  { // converted something, try to put it out
162  size_t _Count = _Dest - _Buf;
163  if (0 < _Count
164  && _Byte_traits::eq_int_type(
165  _Byte_traits::eof(),
166  (typename _Traits::int_type)_Mystrbuf->sputn(
167  _Buf,
168  (_STD streamsize)_Count)))
169  return (_Traits::eof()); // write failed
170 
171  if (_Src != &_Ch)
172  return (_Meta); // converted whole element
173 
174  if (0 < _Count)
175  ;
176  else if (_Str.size() < 4 * _STRING_INC)
177  _Str.append(_STRING_INC, '\0'); // try with more space
178  else
179  return (_Traits::eof()); // conversion failed
180  break;
181  }
182 
183  case _Codecvt::noconv:
184  if (_Traits::eq_int_type(
185  _Traits::eof(),
186  (typename _Traits::int_type)_Mystrbuf->sputn(
187  (char *)&_Ch,
188  (_STD streamsize)sizeof (_Elem))))
189  return (_Traits::eof());
190  else
191  return (_Meta); // put native byte order
192 
193  default:
194  return (_Traits::eof()); // conversion failed
195  }
196  }
197  }
_Mode _Status
Definition: wbuffer:315
_Longlong streamsize
Definition: iosfwd:22
unsigned int _Count
Definition: xcomplex:668
state_type _State
Definition: wbuffer:312
Definition: regex:1539
size_t _Nback
Definition: wbuffer:316
_Mysb * _Mystrbuf
Definition: wbuffer:314
const _Elem * c_str() const _NOEXCEPT
Definition: xstring:1741
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
_STD string _Str
Definition: wbuffer:318
_Myt & assign(_Myt &&_Right) _NOEXCEPT
Definition: xstring:945
size_type size() const _NOEXCEPT
Definition: xstring:1763
_Myt & append(_XSTD initializer_list< _Elem > _Ilist)
Definition: xstring:998
_Codecvt * _Pcvt
Definition: wbuffer:313
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
virtual int_type stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::pbackfail ( int_type  _Meta = _Traits::eof())
inlineprotectedvirtual
200  { // put an element back to stream
201  if (sizeof (_Myback) / sizeof (_Myback[0]) <= _Nback
202  || _Status == _Wrote)
203  return (_Traits::eof()); // nowhere to put back
204  else
205  { // enough room, put it back
206  if (!_Traits::eq_int_type(_Traits::eof(), _Meta))
207  _Myback[_Nback] = _Traits::to_char_type(_Meta);
208  ++_Nback;
209  if (_Status == _Unused)
210  _Status = _Got;
211  return (_Meta);
212  }
213  }
_Mode _Status
Definition: wbuffer:315
size_t _Nback
Definition: wbuffer:316
_Elem _Myback[8]
Definition: wbuffer:317
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
_Mysb* stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::rdbuf ( ) const
inline
118  { // return byte stream buffer pointer
119  return (_Mystrbuf);
120  }
_Mysb * _Mystrbuf
Definition: wbuffer:314
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
_Mysb* stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::rdbuf ( _Mysb _Strbuf)
inline
123  { // set byte stream buffer pointer
124  _Mysb *_Oldstrbuf = _Mystrbuf;
125  _Mystrbuf = _Strbuf;
126  return (_Oldstrbuf);
127  }
_Mysb * _Mystrbuf
Definition: wbuffer:314
_STD streambuf _Mysb
Definition: wbuffer:38
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
virtual pos_type stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::seekoff ( off_type  ,
_STD ios::seekdir  ,
_STD ios::openmode  = (_STD ios::openmode)(_STD ios::in | _STD ios::out) 
)
inlineprotectedvirtual
245  { // change position by _Off
246  return (pos_type(-1)); // always fail
247  }
_Traits::pos_type pos_type
Definition: wbuffer:42
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
virtual pos_type stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::seekpos ( pos_type  ,
_STD ios::openmode  = (_STD ios::openmode)(_STD ios::in | _STD ios::out) 
)
inlineprotectedvirtual
252  { // change position to _Pos
253  return (pos_type(-1)); // always fail
254  }
_Traits::pos_type pos_type
Definition: wbuffer:42
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
state_type stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::state ( ) const
inline
130  { // get state
131  return (_State);
132  }
state_type _State
Definition: wbuffer:312
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
virtual int_type stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::uflow ( )
inlineprotectedvirtual
229  { // get an element from stream, point past it
230  int_type _Meta;
231 
232  if (0 < _Nback)
233  ;
234  else if (_Traits::eq_int_type(_Traits::eof(), _Meta = _Get_elem()))
235  return (_Meta); // _Get_elem failed, return EOF
236  else
237  _Myback[_Nback++] = _Traits::to_char_type(_Meta);
238  return (_Traits::to_int_type(_Myback[--_Nback]));
239  }
_Traits::int_type int_type
Definition: wbuffer:41
int_type _Get_elem()
Definition: wbuffer:257
size_t _Nback
Definition: wbuffer:316
_Elem _Myback[8]
Definition: wbuffer:317
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
virtual int_type stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::underflow ( )
inlineprotectedvirtual
216  { // get an element from stream, but don't point past it
217  int_type _Meta;
218 
219  if (0 < _Nback)
220  ;
221  else if (_Traits::eq_int_type(_Traits::eof(), _Meta = _Get_elem()))
222  return (_Meta); // _Get_elem failed, return EOF
223  else
224  _Myback[_Nback++] = _Traits::to_char_type(_Meta);
225  return (_Traits::to_int_type(_Myback[_Nback - 1]));
226  }
_Traits::int_type int_type
Definition: wbuffer:41
int_type _Get_elem()
Definition: wbuffer:257
size_t _Nback
Definition: wbuffer:316
_Elem _Myback[8]
Definition: wbuffer:317

Member Data Documentation

template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
_STD locale stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::_Loc
private
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
_Elem stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::_Myback[8]
private
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
_Mysb* stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::_Mystrbuf
private
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
size_t stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::_Nback
private
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
_Codecvt* stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::_Pcvt
private
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
state_type stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::_State
private
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
_Mode stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::_Status
private
template<class _Codecvt, class _Elem = wchar_t, class _Traits = _STD char_traits<_Elem>>
_STD string stdext::cvt::wbuffer_convert< _Codecvt, _Elem, _Traits >::_Str
private

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