STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc > Class Template Reference

Public Types

typedef basic_string< char, char_traits< char >, _Balloc > byte_string
 
typedef basic_string< _Elem, char_traits< _Elem >, _Walloc > wide_string
 
typedef _Codecvt::state_type state_type
 
typedef wide_string::traits_type::int_type int_type
 

Public Member Functions

 wstring_convert ()
 
 wstring_convert (const _Codecvt *_Pcvt_arg)
 
 wstring_convert (const _Codecvt *_Pcvt_arg, state_type _State_arg)
 
 wstring_convert (const byte_string &_Berr_arg)
 
 wstring_convert (const byte_string &_Berr_arg, const wide_string &_Werr_arg)
 
virtual ~wstring_convert () _NOEXCEPT
 
size_t converted () const _NOEXCEPT
 
state_type state () const
 
wide_string from_bytes (char _Byte)
 
wide_string from_bytes (const char *_Ptr)
 
wide_string from_bytes (const byte_string &_Bstr)
 
wide_string from_bytes (const char *_First, const char *_Last)
 
byte_string to_bytes (_Elem _Char)
 
byte_string to_bytes (const _Elem *_Wptr)
 
byte_string to_bytes (const wide_string &_Wstr)
 
byte_string to_bytes (const _Elem *_First, const _Elem *_Last)
 
 wstring_convert (const wstring_convert &)=delete
 
wstring_convertoperator= (const wstring_convert &)=delete
 

Private Types

enum  { _BUF_INC = 8, _BUF_MAX = 16 }
 

Private Member Functions

void _Init (const _Codecvt *_Pcvt_arg=new _Codecvt)
 

Private Attributes

const _Codecvt * _Pcvt
 
locale _Loc
 
byte_string _Berr
 
wide_string _Werr
 
state_type _State
 
bool _Has_state
 
bool _Has_berr
 
bool _Has_werr
 
size_t _Nconv
 

Member Typedef Documentation

template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
typedef basic_string<char, char_traits<char>, _Balloc> wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::byte_string
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
typedef wide_string::traits_type::int_type wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::int_type
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
typedef _Codecvt::state_type wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::state_type
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
typedef basic_string<_Elem, char_traits<_Elem>, _Walloc> wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::wide_string

Member Enumeration Documentation

template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
anonymous enum
private
Enumerator
_BUF_INC 
_BUF_MAX 
311 {_BUF_INC = 8, _BUF_MAX = 16};
Definition: xlocbuf:311
Definition: xlocbuf:311

Constructor & Destructor Documentation

template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::wstring_convert ( )
inline
327  : _Has_berr(false), _Has_werr(false), _Has_state(false)
328  { // construct with no error strings
329  _Init();
330  }
bool _Has_werr
Definition: xlocbuf:510
bool _Has_berr
Definition: xlocbuf:509
bool _Has_state
Definition: xlocbuf:508
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:312
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::wstring_convert ( const _Codecvt *  _Pcvt_arg)
inlineexplicit
333  : _Has_berr(false), _Has_werr(false), _Has_state(false)
334  { // construct with no error strings and codecvt
335  _Init(_Pcvt_arg);
336  }
bool _Has_werr
Definition: xlocbuf:510
bool _Has_berr
Definition: xlocbuf:509
bool _Has_state
Definition: xlocbuf:508
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:312
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::wstring_convert ( const _Codecvt *  _Pcvt_arg,
state_type  _State_arg 
)
inline
339  : _Has_berr(false), _Has_werr(false), _Has_state(true)
340  { // construct with no error strings, codecvt, and state
341  _Init(_Pcvt_arg);
342  _State = _State_arg;
343  }
state_type _State
Definition: xlocbuf:507
bool _Has_werr
Definition: xlocbuf:510
bool _Has_berr
Definition: xlocbuf:509
bool _Has_state
Definition: xlocbuf:508
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:312
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::wstring_convert ( const byte_string _Berr_arg)
inlineexplicit
346  : _Has_berr(true), _Has_werr(false), _Has_state(false),
347  _Berr(_Berr_arg)
348  { // construct with byte error string
349  _Init();
350  }
byte_string _Berr
Definition: xlocbuf:505
bool _Has_werr
Definition: xlocbuf:510
bool _Has_berr
Definition: xlocbuf:509
bool _Has_state
Definition: xlocbuf:508
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:312
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::wstring_convert ( const byte_string _Berr_arg,
const wide_string _Werr_arg 
)
inline
354  : _Has_berr(true), _Has_werr(true), _Has_state(false),
355  _Berr(_Berr_arg), _Werr(_Werr_arg)
356  { // construct with byte and wide error strings
357  _Init();
358  }
byte_string _Berr
Definition: xlocbuf:505
bool _Has_werr
Definition: xlocbuf:510
bool _Has_berr
Definition: xlocbuf:509
wide_string _Werr
Definition: xlocbuf:506
bool _Has_state
Definition: xlocbuf:508
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:312
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
virtual wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::~wstring_convert ( )
inlinevirtual
361  { // destroy the object
362  }
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::wstring_convert ( const wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc > &  )
delete

Member Function Documentation

template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
void wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::_Init ( const _Codecvt *  _Pcvt_arg = new _Codecvt)
inlineprivate
313  { // initialize the object
314  _State = state_type{};
315  _Pcvt = _Pcvt_arg;
316  _Loc = locale(_Loc, _Pcvt);
317  _Nconv = 0;
318  }
_Codecvt::state_type state_type
Definition: xlocbuf:323
const _Codecvt * _Pcvt
Definition: xlocbuf:503
state_type _State
Definition: xlocbuf:507
size_t _Nconv
Definition: xlocbuf:511
Definition: xlocale:97
locale _Loc
Definition: xlocbuf:504
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
size_t wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::converted ( ) const
inline
365  { // get conversion count
366  return (_Nconv);
367  }
size_t _Nconv
Definition: xlocbuf:511
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
wide_string wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::from_bytes ( char  _Byte)
inline
375  { // convert a byte to a wide string
376  return (from_bytes(&_Byte, &_Byte + 1));
377  }
wide_string from_bytes(char _Byte)
Definition: xlocbuf:374
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
wide_string wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::from_bytes ( const char _Ptr)
inline
380  { // convert a NTBS to a wide string
381  return (from_bytes(_Ptr, _Ptr + _CSTD strlen(_Ptr)));
382  }
_Check_return_ size_t __cdecl strlen(_In_z_ char const *_Str)
wide_string from_bytes(char _Byte)
Definition: xlocbuf:374
#define _CSTD
Definition: yvals.h:570
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
wide_string wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::from_bytes ( const byte_string _Bstr)
inline
385  { // convert a byte string to a wide string
386  const char *_Ptr = _Bstr.c_str();
387  return (from_bytes(_Ptr, _Ptr + _Bstr.size()));
388  }
wide_string from_bytes(char _Byte)
Definition: xlocbuf:374
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
wide_string wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::from_bytes ( const char _First,
const char _Last 
)
inline
391  { // convert byte sequence [_First, _Last) to a wide string
392  wide_string _Wbuf, _Wstr;
393  const char *_First_sav = _First;
394 
395  if (!_Has_state)
396  _State = state_type{}; // reset state if not remembered
397  _Wbuf.append((_CSTD size_t)_BUF_INC, (_Elem)'\0');
398  for (_Nconv = 0; _First != _Last; _Nconv = _First - _First_sav)
399  { // convert one or more bytes
400  _Elem *_Dest = &*_Wbuf.begin();
401  _Elem *_Dnext;
402 
403  switch (_Pcvt->in(_State,
404  _First, _Last, _First,
405  _Dest, _Dest + _Wbuf.size(), _Dnext))
406  { // test result of converting one or more bytes
407  case _Codecvt::partial:
408  case _Codecvt::ok:
409  if (_Dest < _Dnext)
410  _Wstr.append(_Dest, (_CSTD size_t)(_Dnext - _Dest));
411  else if (_Wbuf.size() < _BUF_MAX)
412  _Wbuf.append((_CSTD size_t)_BUF_INC, '\0');
413  else if (_Has_werr)
414  return (_Werr);
415  else
416  _THROW_NCEE(range_error, "bad conversion");
417  break;
418 
419  case _Codecvt::noconv:
420  for (; _First != _Last; ++_First)
421  _Wstr.append((_CSTD size_t)1,
422  (_Elem)(unsigned char)*_First);
423  break; // no conversion, just copy code values
424 
425  default:
426  if (_Has_werr)
427  return (_Werr);
428  else
429  _THROW_NCEE(range_error, "bad conversion");
430  }
431  }
432  return (_Wstr);
433  }
_Codecvt::state_type state_type
Definition: xlocbuf:323
Definition: stdexcept:240
const _Codecvt * _Pcvt
Definition: xlocbuf:503
unsigned _Dest
Definition: mbstring.h:107
state_type _State
Definition: xlocbuf:507
size_t _Nconv
Definition: xlocbuf:511
bool _Has_werr
Definition: xlocbuf:510
Definition: xlocbuf:311
Definition: xlocbuf:311
#define _THROW_NCEE(x, y)
Definition: xstddef:51
wide_string _Werr
Definition: xlocbuf:506
bool _Has_state
Definition: xlocbuf:508
#define _CSTD
Definition: yvals.h:570
basic_string< _Elem, char_traits< _Elem >, _Walloc > wide_string
Definition: xlocbuf:322
_FwdIt _Last
Definition: algorithm:1936
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
wstring_convert& wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::operator= ( const wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc > &  )
delete
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
state_type wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::state ( ) const
inline
370  { // get state
371  return (_State);
372  }
state_type _State
Definition: xlocbuf:507
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
byte_string wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::to_bytes ( _Elem  _Char)
inline
436  { // convert a wide char to a byte string
437  return (to_bytes(&_Char, &_Char + 1));
438  }
byte_string to_bytes(_Elem _Char)
Definition: xlocbuf:435
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
byte_string wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::to_bytes ( const _Elem *  _Wptr)
inline
441  { // convert a NTWCS to a byte string
442  const _Elem *_Next = _Wptr;
443  for (; (int_type)*_Next != 0; ++_Next)
444  ;
445  return (to_bytes(_Wptr, _Next));
446  }
wide_string::traits_type::int_type int_type
Definition: xlocbuf:324
byte_string to_bytes(_Elem _Char)
Definition: xlocbuf:435
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
byte_string wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::to_bytes ( const wide_string _Wstr)
inline
449  { // convert a wide string to a byte string
450  const _Elem *_Wptr = _Wstr.c_str();
451  return (to_bytes(_Wptr, _Wptr + _Wstr.size()));
452  }
byte_string to_bytes(_Elem _Char)
Definition: xlocbuf:435
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
byte_string wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::to_bytes ( const _Elem *  _First,
const _Elem *  _Last 
)
inline
455  { // convert wide sequence [_First, _Last) to a byte string
456  byte_string _Bbuf, _Bstr;
457  const _Elem *_First_sav = _First;
458 
459  if (!_Has_state)
460  _State = state_type{}; // reset state if not remembered
461  _Bbuf.append((_CSTD size_t)_BUF_INC, '\0');
462  for (_Nconv = 0; _First != _Last; _Nconv = _First - _First_sav)
463  { // convert one or more wide chars
464  char *_Dest = &*_Bbuf.begin();
465  char *_Dnext;
466 
467  switch (_Pcvt->out(_State,
468  _First, _Last, _First,
469  _Dest, _Dest + _Bbuf.size(), _Dnext))
470  { // test result of converting one or more wide chars
471  case _Codecvt::partial:
472  case _Codecvt::ok:
473  if (_Dest < _Dnext)
474  _Bstr.append(_Dest, (_CSTD size_t)(_Dnext - _Dest));
475  else if (_Bbuf.size() < _BUF_MAX)
476  _Bbuf.append((_CSTD size_t)_BUF_INC, '\0');
477  else if (_Has_berr)
478  return (_Berr);
479  else
480  _THROW_NCEE(range_error, "bad conversion");
481  break;
482 
483  case _Codecvt::noconv:
484  for (; _First != _Last; ++_First)
485  _Bstr.append((_CSTD size_t)1,
486  (char)(int_type)*_First);
487  break; // no conversion, just copy code values
488 
489  default:
490  if (_Has_berr)
491  return (_Berr);
492  else
493  _THROW_NCEE(range_error, "bad conversion");
494  }
495  }
496  return (_Bstr);
497  }
_Codecvt::state_type state_type
Definition: xlocbuf:323
Definition: stdexcept:240
const _Codecvt * _Pcvt
Definition: xlocbuf:503
unsigned _Dest
Definition: mbstring.h:107
state_type _State
Definition: xlocbuf:507
size_t _Nconv
Definition: xlocbuf:511
wide_string::traits_type::int_type int_type
Definition: xlocbuf:324
byte_string _Berr
Definition: xlocbuf:505
Definition: xlocbuf:311
basic_string< char, char_traits< char >, _Balloc > byte_string
Definition: xlocbuf:321
Definition: xlocbuf:311
#define _THROW_NCEE(x, y)
Definition: xstddef:51
bool _Has_berr
Definition: xlocbuf:509
bool _Has_state
Definition: xlocbuf:508
#define _CSTD
Definition: yvals.h:570
_FwdIt _Last
Definition: algorithm:1936

Member Data Documentation

template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
byte_string wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::_Berr
private
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
bool wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::_Has_berr
private
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
bool wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::_Has_state
private
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
bool wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::_Has_werr
private
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
locale wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::_Loc
private
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
size_t wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::_Nconv
private
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
const _Codecvt* wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::_Pcvt
private
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
state_type wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::_State
private
template<class _Codecvt , class _Elem = wchar_t, class _Walloc = allocator<_Elem>, class _Balloc = allocator<char>>
wide_string wstring_convert< _Codecvt, _Elem, _Walloc, _Balloc >::_Werr
private

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