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
 
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 
315 {_BUF_INC = 8, _BUF_MAX = 16};
Definition: xlocbuf:315
Definition: xlocbuf:315

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
332  : _Has_berr(false), _Has_werr(false), _Has_state(false)
333  { // construct with no error strings
334  _Init();
335  }
bool _Has_werr
Definition: xlocbuf:517
bool _Has_berr
Definition: xlocbuf:516
bool _Has_state
Definition: xlocbuf:515
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:316
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)
inline
338  : _Has_berr(false), _Has_werr(false), _Has_state(false)
339  { // construct with no error strings and codecvt
340  _Init(_Pcvt_arg);
341  }
bool _Has_werr
Definition: xlocbuf:517
bool _Has_berr
Definition: xlocbuf:516
bool _Has_state
Definition: xlocbuf:515
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:316
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
344  : _Has_berr(false), _Has_werr(false), _Has_state(true)
345  { // construct with no error strings, codecvt, and state
346  _Init(_Pcvt_arg);
347  _State = _State_arg;
348  }
state_type _State
Definition: xlocbuf:514
bool _Has_werr
Definition: xlocbuf:517
bool _Has_berr
Definition: xlocbuf:516
bool _Has_state
Definition: xlocbuf:515
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:316
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)
inline
351  : _Has_berr(true), _Has_werr(false), _Has_state(false),
352  _Berr(_Berr_arg)
353  { // construct with byte error string
354  _Init();
355  }
byte_string _Berr
Definition: xlocbuf:512
bool _Has_werr
Definition: xlocbuf:517
bool _Has_berr
Definition: xlocbuf:516
bool _Has_state
Definition: xlocbuf:515
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:316
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
359  : _Has_berr(true), _Has_werr(true), _Has_state(false),
360  _Berr(_Berr_arg), _Werr(_Werr_arg)
361  { // construct with byte and wide error strings
362  _Init();
363  }
byte_string _Berr
Definition: xlocbuf:512
bool _Has_werr
Definition: xlocbuf:517
bool _Has_berr
Definition: xlocbuf:516
wide_string _Werr
Definition: xlocbuf:513
bool _Has_state
Definition: xlocbuf:515
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:316
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
366  { // destroy the object
367  }
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
317  { // initialize the object
318  static state_type _State0;
319  _State = _State0;
320  _Pcvt = _Pcvt_arg;
321  _Loc = locale(_Loc, _Pcvt);
322  _Nconv = 0;
323  }
_Codecvt::state_type state_type
Definition: xlocbuf:328
const _Codecvt * _Pcvt
Definition: xlocbuf:510
state_type _State
Definition: xlocbuf:514
size_t _Nconv
Definition: xlocbuf:518
Definition: xlocale:62
locale _Loc
Definition: xlocbuf:511
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
370  { // get conversion count
371  return (_Nconv);
372  }
size_t _Nconv
Definition: xlocbuf:518
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
380  { // convert a byte to a wide string
381  return (from_bytes(&_Byte, &_Byte + 1));
382  }
wide_string from_bytes(char _Byte)
Definition: xlocbuf:379
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
385  { // convert a NTBS to a wide string
386  return (from_bytes(_Ptr, _Ptr + strlen(_Ptr)));
387  }
wide_string from_bytes(char _Byte)
Definition: xlocbuf:379
_Check_return_ size_t __cdecl strlen(_In_z_ const char *_Str)
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
390  { // convert a byte string to a wide string
391  const char *_Ptr = _Bstr.c_str();
392  return (from_bytes(_Ptr, _Ptr + _Bstr.size()));
393  }
wide_string from_bytes(char _Byte)
Definition: xlocbuf:379
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
396  { // convert byte sequence [_First, _Last) to a wide string
397  static state_type _State0;
398  wide_string _Wbuf, _Wstr;
399  const char *_First_sav = _First;
400 
401  if (!_Has_state)
402  _State = _State0; // reset state if not remembered
403  _Wbuf.append((_CSTD size_t)_BUF_INC, (_Elem)'\0');
404  for (_Nconv = 0; _First != _Last; _Nconv = _First - _First_sav)
405  { // convert one or more bytes
406  _Elem *_Dest = &*_Wbuf.begin();
407  _Elem *_Dnext;
408 
409  switch (_Pcvt->in(_State,
410  _First, _Last, _First,
411  _Dest, _Dest + _Wbuf.size(), _Dnext))
412  { // test result of converting one or more bytes
413  case _Codecvt::partial:
414  case _Codecvt::ok:
415  if (_Dest < _Dnext)
416  _Wstr.append(_Dest, (_CSTD size_t)(_Dnext - _Dest));
417  else if (_Wbuf.size() < _BUF_MAX)
418  _Wbuf.append((_CSTD size_t)_BUF_INC, '\0');
419  else if (_Has_werr)
420  return (_Werr);
421  else
422  _THROW_NCEE(range_error, "bad conversion");
423  break;
424 
425  case _Codecvt::noconv:
426  for (; _First != _Last; ++_First)
427  _Wstr.append((_CSTD size_t)1,
428  (_Elem)(unsigned char)*_First);
429  break; // no conversion, just copy code values
430 
431  default:
432  if (_Has_werr)
433  return (_Werr);
434  else
435  _THROW_NCEE(range_error, "bad conversion");
436  }
437  }
438  return (_Wstr);
439  }
_Codecvt::state_type state_type
Definition: xlocbuf:328
Definition: xlocbuf:315
Definition: stdexcept:249
const _Codecvt * _Pcvt
Definition: xlocbuf:510
Definition: xlocbuf:315
state_type _State
Definition: xlocbuf:514
size_t _Nconv
Definition: xlocbuf:518
bool _Has_werr
Definition: xlocbuf:517
#define _THROW_NCEE(x, y)
Definition: xstddef:79
wide_string _Werr
Definition: xlocbuf:513
bool _Has_state
Definition: xlocbuf:515
#define _CSTD
Definition: yvals.h:559
basic_string< _Elem, char_traits< _Elem >, _Walloc > wide_string
Definition: xlocbuf:327
_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
375  { // get state
376  return (_State);
377  }
state_type _State
Definition: xlocbuf:514
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
442  { // convert a wide char to a byte string
443  return (to_bytes(&_Char, &_Char + 1));
444  }
byte_string to_bytes(_Elem _Char)
Definition: xlocbuf:441
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
447  { // convert a NTWCS to a byte string
448  const _Elem *_Next = _Wptr;
449  for (; (int_type)*_Next != 0; ++_Next)
450  ;
451  return (to_bytes(_Wptr, _Next));
452  }
wide_string::traits_type::int_type int_type
Definition: xlocbuf:329
byte_string to_bytes(_Elem _Char)
Definition: xlocbuf:441
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
455  { // convert a wide string to a byte string
456  const _Elem *_Wptr = _Wstr.c_str();
457  return (to_bytes(_Wptr, _Wptr + _Wstr.size()));
458  }
byte_string to_bytes(_Elem _Char)
Definition: xlocbuf:441
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
461  { // convert wide sequence [_First, _Last) to a byte string
462  static state_type _State0;
463  byte_string _Bbuf, _Bstr;
464  const _Elem *_First_sav = _First;
465 
466  if (!_Has_state)
467  _State = _State0; // reset state if not remembered
468  _Bbuf.append((_CSTD size_t)_BUF_INC, '\0');
469  for (_Nconv = 0; _First != _Last; _Nconv = _First - _First_sav)
470  { // convert one or more wide chars
471  char *_Dest = &*_Bbuf.begin();
472  char *_Dnext;
473 
474  switch (_Pcvt->out(_State,
475  _First, _Last, _First,
476  _Dest, _Dest + _Bbuf.size(), _Dnext))
477  { // test result of converting one or more wide chars
478  case _Codecvt::partial:
479  case _Codecvt::ok:
480  if (_Dest < _Dnext)
481  _Bstr.append(_Dest, (_CSTD size_t)(_Dnext - _Dest));
482  else if (_Bbuf.size() < _BUF_MAX)
483  _Bbuf.append((_CSTD size_t)_BUF_INC, '\0');
484  else if (_Has_berr)
485  return (_Berr);
486  else
487  _THROW_NCEE(range_error, "bad conversion");
488  break;
489 
490  case _Codecvt::noconv:
491  for (; _First != _Last; ++_First)
492  _Bstr.append((_CSTD size_t)1,
493  (char)(int_type)*_First);
494  break; // no conversion, just copy code values
495 
496  default:
497  if (_Has_berr)
498  return (_Berr);
499  else
500  _THROW_NCEE(range_error, "bad conversion");
501  }
502  }
503  return (_Bstr);
504  }
_Codecvt::state_type state_type
Definition: xlocbuf:328
Definition: xlocbuf:315
Definition: stdexcept:249
const _Codecvt * _Pcvt
Definition: xlocbuf:510
Definition: xlocbuf:315
state_type _State
Definition: xlocbuf:514
size_t _Nconv
Definition: xlocbuf:518
wide_string::traits_type::int_type int_type
Definition: xlocbuf:329
byte_string _Berr
Definition: xlocbuf:512
basic_string< char, char_traits< char >, _Balloc > byte_string
Definition: xlocbuf:326
#define _THROW_NCEE(x, y)
Definition: xstddef:79
bool _Has_berr
Definition: xlocbuf:516
bool _Has_state
Definition: xlocbuf:515
#define _CSTD
Definition: yvals.h:559
_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: