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

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
324  : _Has_berr(false), _Has_werr(false), _Has_state(false)
325  { // construct with no error strings
326  _Init();
327  }
bool _Has_werr
Definition: xlocbuf:507
bool _Has_berr
Definition: xlocbuf:506
bool _Has_state
Definition: xlocbuf:505
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:309
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
330  : _Has_berr(false), _Has_werr(false), _Has_state(false)
331  { // construct with no error strings and codecvt
332  _Init(_Pcvt_arg);
333  }
bool _Has_werr
Definition: xlocbuf:507
bool _Has_berr
Definition: xlocbuf:506
bool _Has_state
Definition: xlocbuf:505
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:309
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
336  : _Has_berr(false), _Has_werr(false), _Has_state(true)
337  { // construct with no error strings, codecvt, and state
338  _Init(_Pcvt_arg);
339  _State = _State_arg;
340  }
state_type _State
Definition: xlocbuf:504
bool _Has_werr
Definition: xlocbuf:507
bool _Has_berr
Definition: xlocbuf:506
bool _Has_state
Definition: xlocbuf:505
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:309
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
343  : _Has_berr(true), _Has_werr(false), _Has_state(false),
344  _Berr(_Berr_arg)
345  { // construct with byte error string
346  _Init();
347  }
byte_string _Berr
Definition: xlocbuf:502
bool _Has_werr
Definition: xlocbuf:507
bool _Has_berr
Definition: xlocbuf:506
bool _Has_state
Definition: xlocbuf:505
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:309
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
351  : _Has_berr(true), _Has_werr(true), _Has_state(false),
352  _Berr(_Berr_arg), _Werr(_Werr_arg)
353  { // construct with byte and wide error strings
354  _Init();
355  }
byte_string _Berr
Definition: xlocbuf:502
bool _Has_werr
Definition: xlocbuf:507
bool _Has_berr
Definition: xlocbuf:506
wide_string _Werr
Definition: xlocbuf:503
bool _Has_state
Definition: xlocbuf:505
void _Init(const _Codecvt *_Pcvt_arg=new _Codecvt)
Definition: xlocbuf:309
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
358  { // destroy the object
359  }
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
310  { // initialize the object
311  _State = state_type{};
312  _Pcvt = _Pcvt_arg;
313  _Loc = locale(_Loc, _Pcvt);
314  _Nconv = 0;
315  }
_Codecvt::state_type state_type
Definition: xlocbuf:320
const _Codecvt * _Pcvt
Definition: xlocbuf:500
state_type _State
Definition: xlocbuf:504
size_t _Nconv
Definition: xlocbuf:508
Definition: xlocale:98
locale _Loc
Definition: xlocbuf:501
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
362  { // get conversion count
363  return (_Nconv);
364  }
size_t _Nconv
Definition: xlocbuf:508
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
372  { // convert a byte to a wide string
373  return (from_bytes(&_Byte, &_Byte + 1));
374  }
wide_string from_bytes(char _Byte)
Definition: xlocbuf:371
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
377  { // convert a NTBS to a wide string
378  return (from_bytes(_Ptr, _Ptr + _CSTD strlen(_Ptr)));
379  }
wide_string from_bytes(char _Byte)
Definition: xlocbuf:371
#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
382  { // convert a byte string to a wide string
383  const char *_Ptr = _Bstr.c_str();
384  return (from_bytes(_Ptr, _Ptr + _Bstr.size()));
385  }
wide_string from_bytes(char _Byte)
Definition: xlocbuf:371
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
388  { // convert byte sequence [_First, _Last) to a wide string
389  wide_string _Wbuf, _Wstr;
390  const char *_First_sav = _First;
391 
392  if (!_Has_state)
393  _State = state_type{}; // reset state if not remembered
394  _Wbuf.append((_CSTD size_t)_BUF_INC, (_Elem)'\0');
395  for (_Nconv = 0; _First != _Last; _Nconv = _First - _First_sav)
396  { // convert one or more bytes
397  _Elem *_Dest = &*_Wbuf.begin();
398  _Elem *_Dnext;
399 
400  switch (_Pcvt->in(_State,
401  _First, _Last, _First,
402  _Dest, _Dest + _Wbuf.size(), _Dnext))
403  { // test result of converting one or more bytes
404  case _Codecvt::partial:
405  case _Codecvt::ok:
406  if (_Dest < _Dnext)
407  _Wstr.append(_Dest, (_CSTD size_t)(_Dnext - _Dest));
408  else if (_Wbuf.size() < _BUF_MAX)
409  _Wbuf.append((_CSTD size_t)_BUF_INC, '\0');
410  else if (_Has_werr)
411  return (_Werr);
412  else
413  _THROW_NCEE(range_error, "bad conversion");
414  break;
415 
416  case _Codecvt::noconv:
417  for (; _First != _Last; ++_First)
418  _Wstr.append((_CSTD size_t)1,
419  (_Elem)(unsigned char)*_First);
420  break; // no conversion, just copy code values
421 
422  default:
423  if (_Has_werr)
424  return (_Werr);
425  else
426  _THROW_NCEE(range_error, "bad conversion");
427  }
428  }
429  return (_Wstr);
430  }
_Codecvt::state_type state_type
Definition: xlocbuf:320
Definition: xlocbuf:308
Definition: stdexcept:239
const _Codecvt * _Pcvt
Definition: xlocbuf:500
state_type _State
Definition: xlocbuf:504
size_t _Nconv
Definition: xlocbuf:508
bool _Has_werr
Definition: xlocbuf:507
#define _THROW_NCEE(x, y)
Definition: xstddef:78
wide_string _Werr
Definition: xlocbuf:503
bool _Has_state
Definition: xlocbuf:505
#define _CSTD
Definition: yvals.h:570
Definition: xlocbuf:308
basic_string< _Elem, char_traits< _Elem >, _Walloc > wide_string
Definition: xlocbuf:319
_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
367  { // get state
368  return (_State);
369  }
state_type _State
Definition: xlocbuf:504
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
433  { // convert a wide char to a byte string
434  return (to_bytes(&_Char, &_Char + 1));
435  }
byte_string to_bytes(_Elem _Char)
Definition: xlocbuf:432
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
438  { // convert a NTWCS to a byte string
439  const _Elem *_Next = _Wptr;
440  for (; (int_type)*_Next != 0; ++_Next)
441  ;
442  return (to_bytes(_Wptr, _Next));
443  }
wide_string::traits_type::int_type int_type
Definition: xlocbuf:321
byte_string to_bytes(_Elem _Char)
Definition: xlocbuf:432
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
446  { // convert a wide string to a byte string
447  const _Elem *_Wptr = _Wstr.c_str();
448  return (to_bytes(_Wptr, _Wptr + _Wstr.size()));
449  }
byte_string to_bytes(_Elem _Char)
Definition: xlocbuf:432
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
452  { // convert wide sequence [_First, _Last) to a byte string
453  byte_string _Bbuf, _Bstr;
454  const _Elem *_First_sav = _First;
455 
456  if (!_Has_state)
457  _State = state_type{}; // reset state if not remembered
458  _Bbuf.append((_CSTD size_t)_BUF_INC, '\0');
459  for (_Nconv = 0; _First != _Last; _Nconv = _First - _First_sav)
460  { // convert one or more wide chars
461  char *_Dest = &*_Bbuf.begin();
462  char *_Dnext;
463 
464  switch (_Pcvt->out(_State,
465  _First, _Last, _First,
466  _Dest, _Dest + _Bbuf.size(), _Dnext))
467  { // test result of converting one or more wide chars
468  case _Codecvt::partial:
469  case _Codecvt::ok:
470  if (_Dest < _Dnext)
471  _Bstr.append(_Dest, (_CSTD size_t)(_Dnext - _Dest));
472  else if (_Bbuf.size() < _BUF_MAX)
473  _Bbuf.append((_CSTD size_t)_BUF_INC, '\0');
474  else if (_Has_berr)
475  return (_Berr);
476  else
477  _THROW_NCEE(range_error, "bad conversion");
478  break;
479 
480  case _Codecvt::noconv:
481  for (; _First != _Last; ++_First)
482  _Bstr.append((_CSTD size_t)1,
483  (char)(int_type)*_First);
484  break; // no conversion, just copy code values
485 
486  default:
487  if (_Has_berr)
488  return (_Berr);
489  else
490  _THROW_NCEE(range_error, "bad conversion");
491  }
492  }
493  return (_Bstr);
494  }
_Codecvt::state_type state_type
Definition: xlocbuf:320
Definition: xlocbuf:308
Definition: stdexcept:239
const _Codecvt * _Pcvt
Definition: xlocbuf:500
state_type _State
Definition: xlocbuf:504
size_t _Nconv
Definition: xlocbuf:508
wide_string::traits_type::int_type int_type
Definition: xlocbuf:321
byte_string _Berr
Definition: xlocbuf:502
basic_string< char, char_traits< char >, _Balloc > byte_string
Definition: xlocbuf:318
#define _THROW_NCEE(x, y)
Definition: xstddef:78
bool _Has_berr
Definition: xlocbuf:506
bool _Has_state
Definition: xlocbuf:505
#define _CSTD
Definition: yvals.h:570
Definition: xlocbuf:308
_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: