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
stdext::cvt::wstring_convert< _Codecvt, _Elem > Class Template Reference

Public Types

typedef _STD basic_string< char > byte_string
 
typedef _STD basic_string< _Elem > wide_string
 
typedef _Codecvt::state_type state_type
 
typedef wide_string::traits_type::int_type int_type
 

Public Member Functions

 wstring_convert ()
 
 wstring_convert (_Codecvt *_Pcvt_arg)
 
 wstring_convert (_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
 
 wstring_convert (const wstring_convert &)=delete
 
wstring_convertoperator= (const wstring_convert &)=delete
 
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)
 

Private Types

enum  { _BUF_INC = 8, _BUF_MAX = 16 }
 

Private Member Functions

void _Init (_Codecvt *_Pcvt_arg=new _Codecvt)
 

Private Attributes

_Codecvt * _Pcvt
 
_STD 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>
typedef _STD basic_string<char> stdext::cvt::wstring_convert< _Codecvt, _Elem >::byte_string
template<class _Codecvt , class _Elem = wchar_t>
typedef wide_string::traits_type::int_type stdext::cvt::wstring_convert< _Codecvt, _Elem >::int_type
template<class _Codecvt , class _Elem = wchar_t>
typedef _Codecvt::state_type stdext::cvt::wstring_convert< _Codecvt, _Elem >::state_type
template<class _Codecvt , class _Elem = wchar_t>
typedef _STD basic_string<_Elem> stdext::cvt::wstring_convert< _Codecvt, _Elem >::wide_string

Member Enumeration Documentation

template<class _Codecvt , class _Elem = wchar_t>
anonymous enum
private
Enumerator
_BUF_INC 
_BUF_MAX 
24 {_BUF_INC = 8, _BUF_MAX = 16};

Constructor & Destructor Documentation

template<class _Codecvt , class _Elem = wchar_t>
stdext::cvt::wstring_convert< _Codecvt, _Elem >::wstring_convert ( )
inline
40  : _Has_berr(false), _Has_werr(false), _Has_state(false)
41  { // construct with no error strings
42  _Init();
43  }
bool _Has_state
Definition: wstring:223
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:26
bool _Has_berr
Definition: wstring:224
bool _Has_werr
Definition: wstring:225
template<class _Codecvt , class _Elem = wchar_t>
stdext::cvt::wstring_convert< _Codecvt, _Elem >::wstring_convert ( _Codecvt *  _Pcvt_arg)
inlineexplicit
46  : _Has_berr(false), _Has_werr(false), _Has_state(false)
47  { // construct with no error strings and codecvt
48  _Init(_Pcvt_arg);
49  }
bool _Has_state
Definition: wstring:223
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:26
bool _Has_berr
Definition: wstring:224
bool _Has_werr
Definition: wstring:225
template<class _Codecvt , class _Elem = wchar_t>
stdext::cvt::wstring_convert< _Codecvt, _Elem >::wstring_convert ( _Codecvt *  _Pcvt_arg,
state_type  _State_arg 
)
inline
52  : _Has_berr(false), _Has_werr(false), _Has_state(true)
53  { // construct with no error strings, codecvt, and state
54  _Init(_Pcvt_arg);
55  _State = _State_arg;
56  }
state_type _State
Definition: wstring:222
bool _Has_state
Definition: wstring:223
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:26
bool _Has_berr
Definition: wstring:224
bool _Has_werr
Definition: wstring:225
template<class _Codecvt , class _Elem = wchar_t>
stdext::cvt::wstring_convert< _Codecvt, _Elem >::wstring_convert ( const byte_string _Berr_arg)
inlineexplicit
59  : _Has_berr(true), _Has_werr(false), _Has_state(false),
60  _Berr(_Berr_arg)
61  { // construct with byte error string
62  _Init();
63  }
byte_string _Berr
Definition: wstring:220
bool _Has_state
Definition: wstring:223
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:26
bool _Has_berr
Definition: wstring:224
bool _Has_werr
Definition: wstring:225
template<class _Codecvt , class _Elem = wchar_t>
stdext::cvt::wstring_convert< _Codecvt, _Elem >::wstring_convert ( const byte_string _Berr_arg,
const wide_string _Werr_arg 
)
inline
67  : _Has_berr(true), _Has_werr(true), _Has_state(false),
68  _Berr(_Berr_arg), _Werr(_Werr_arg)
69  { // construct with byte and wide error strings
70  _Init();
71  }
byte_string _Berr
Definition: wstring:220
bool _Has_state
Definition: wstring:223
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:26
bool _Has_berr
Definition: wstring:224
wide_string _Werr
Definition: wstring:221
bool _Has_werr
Definition: wstring:225
template<class _Codecvt , class _Elem = wchar_t>
virtual stdext::cvt::wstring_convert< _Codecvt, _Elem >::~wstring_convert ( )
inlinevirtual
74  { // destroy the object
75  }
template<class _Codecvt , class _Elem = wchar_t>
stdext::cvt::wstring_convert< _Codecvt, _Elem >::wstring_convert ( const wstring_convert< _Codecvt, _Elem > &  )
delete

Member Function Documentation

template<class _Codecvt , class _Elem = wchar_t>
void stdext::cvt::wstring_convert< _Codecvt, _Elem >::_Init ( _Codecvt *  _Pcvt_arg = new _Codecvt)
inlineprivate
27  { // initialize the object
28  _Pcvt = _Pcvt_arg;
30  _Nconv = 0;
31  }
size_t _Nconv
Definition: wstring:226
_STD locale _Loc
Definition: wstring:219
_Codecvt * _Pcvt
Definition: wstring:218
#define _ADDFAC(loc, pfac)
Definition: xlocale:545
template<class _Codecvt , class _Elem = wchar_t>
size_t stdext::cvt::wstring_convert< _Codecvt, _Elem >::converted ( ) const
inline
81  { // get conversion count
82  return (_Nconv);
83  }
size_t _Nconv
Definition: wstring:226
template<class _Codecvt , class _Elem = wchar_t>
wide_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::from_bytes ( char  _Byte)
inline
91  { // convert a byte to a wide string
92  return (from_bytes(&_Byte, &_Byte + 1));
93  }
wide_string from_bytes(char _Byte)
Definition: wstring:90
template<class _Codecvt , class _Elem = wchar_t>
wide_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::from_bytes ( const char *  _Ptr)
inline
96  { // convert a NTBS to a wide string
97  return (from_bytes(_Ptr, _Ptr + _CSTD strlen(_Ptr)));
98  }
wide_string from_bytes(char _Byte)
Definition: wstring:90
#define _CSTD
Definition: yvals.h:570
template<class _Codecvt , class _Elem = wchar_t>
wide_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::from_bytes ( const byte_string _Bstr)
inline
101  { // convert a byte string to a wide string
102  const char *_Ptr = _Bstr.c_str();
103  return (from_bytes(_Ptr, _Ptr + _Bstr.size()));
104  }
wide_string from_bytes(char _Byte)
Definition: wstring:90
template<class _Codecvt , class _Elem = wchar_t>
wide_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::from_bytes ( const char *  _First,
const char *  _Last 
)
inline
107  { // convert byte sequence [_First, _Last) to a wide string
108  static state_type _State0;
109  wide_string _Wbuf, _Wstr;
110  const char *_First_sav = _First;
111 
112  if (!_Has_state)
113  _State = _State0; // reset state if not remembered
114  _Wbuf.append((_CSTD size_t)_BUF_INC, (_Elem)'\0');
115  for (_Nconv = 0; _First != _Last; _Nconv = _First - _First_sav)
116  { // convert one or more bytes
117  _Elem *_Dest = &*_Wbuf.begin();
118  _Elem *_Dnext;
119 
120  switch (_Pcvt->in(_State,
121  _First, _Last, _First,
122  _Dest, _Dest + _Wbuf.size(), _Dnext))
123  { // test result of converting one or more bytes
124  case _Codecvt::partial:
125  case _Codecvt::ok:
126  if (_Dest < _Dnext)
127  _Wstr.append(_Dest, (_CSTD size_t)(_Dnext - _Dest));
128  else if (_Wbuf.size() < _BUF_MAX)
129  _Wbuf.append((_CSTD size_t)_BUF_INC, '\0');
130  else if (_Has_werr)
131  return (_Werr);
132  else
133  _THROW(_STD range_error, "bad conversion");
134  break;
135 
136  case _Codecvt::noconv:
137  for (; _First != _Last; ++_First)
138  _Wstr.append((_CSTD size_t)1,
139  (_Elem)(unsigned char)*_First);
140  break; // no conversion, just copy code values
141 
142  default:
143  if (_Has_werr)
144  return (_Werr);
145  else
146  _THROW(_STD range_error, "bad conversion");
147  }
148  }
149  return (_Wstr);
150  }
size_t _Nconv
Definition: wstring:226
Definition: stdexcept:239
state_type _State
Definition: wstring:222
bool _Has_state
Definition: wstring:223
wide_string _Werr
Definition: wstring:221
bool _Has_werr
Definition: wstring:225
#define _THROW(x, y)
Definition: xstddef:77
_Codecvt * _Pcvt
Definition: wstring:218
_STD basic_string< _Elem > wide_string
Definition: wstring:35
#define _CSTD
Definition: yvals.h:570
_Codecvt::state_type state_type
Definition: wstring:36
_FwdIt _Last
Definition: algorithm:1936
template<class _Codecvt , class _Elem = wchar_t>
wstring_convert& stdext::cvt::wstring_convert< _Codecvt, _Elem >::operator= ( const wstring_convert< _Codecvt, _Elem > &  )
delete
template<class _Codecvt , class _Elem = wchar_t>
state_type stdext::cvt::wstring_convert< _Codecvt, _Elem >::state ( ) const
inline
86  { // get state
87  return (_State);
88  }
state_type _State
Definition: wstring:222
template<class _Codecvt , class _Elem = wchar_t>
byte_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::to_bytes ( _Elem  _Char)
inline
153  { // convert a wide char to a byte string
154  return (to_bytes(&_Char, &_Char + 1));
155  }
byte_string to_bytes(_Elem _Char)
Definition: wstring:152
template<class _Codecvt , class _Elem = wchar_t>
byte_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::to_bytes ( const _Elem *  _Wptr)
inline
158  { // convert a NTWCS to a byte string
159  const _Elem *_Next = _Wptr;
160  for (; (int_type)*_Next != 0; ++_Next)
161  ;
162  return (to_bytes(_Wptr, _Next));
163  }
wide_string::traits_type::int_type int_type
Definition: wstring:37
byte_string to_bytes(_Elem _Char)
Definition: wstring:152
template<class _Codecvt , class _Elem = wchar_t>
byte_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::to_bytes ( const wide_string _Wstr)
inline
166  { // convert a wide string to a byte string
167  const _Elem *_Wptr = _Wstr.c_str();
168  return (to_bytes(_Wptr, _Wptr + _Wstr.size()));
169  }
byte_string to_bytes(_Elem _Char)
Definition: wstring:152
template<class _Codecvt , class _Elem = wchar_t>
byte_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::to_bytes ( const _Elem *  _First,
const _Elem *  _Last 
)
inline
172  { // convert wide sequence [_First, _Last) to a byte string
173  static state_type _State0;
174  byte_string _Bbuf, _Bstr;
175  const _Elem *_First_sav = _First;
176 
177  if (!_Has_state)
178  _State = _State0; // reset state if not remembered
179  _Bbuf.append((_CSTD size_t)_BUF_INC, '\0');
180  for (_Nconv = 0; _First != _Last; _Nconv = _First - _First_sav)
181  { // convert one or more wide chars
182  char *_Dest = &*_Bbuf.begin();
183  char *_Dnext;
184 
185  switch (_Pcvt->out(_State,
186  _First, _Last, _First,
187  _Dest, _Dest + _Bbuf.size(), _Dnext))
188  { // test result of converting one or more wide chars
189  case _Codecvt::partial:
190  case _Codecvt::ok:
191  if (_Dest < _Dnext)
192  _Bstr.append(_Dest, (_CSTD size_t)(_Dnext - _Dest));
193  else if (_Bbuf.size() < _BUF_MAX)
194  _Bbuf.append((_CSTD size_t)_BUF_INC, '\0');
195  else if (_Has_berr)
196  return (_Berr);
197  else
198  _THROW(_STD range_error, "bad conversion");
199  break;
200 
201  case _Codecvt::noconv:
202  for (; _First != _Last; ++_First)
203  _Bstr.append((_CSTD size_t)1,
204  (char)(int_type)*_First);
205  break; // no conversion, just copy code values
206 
207  default:
208  if (_Has_berr)
209  return (_Berr);
210  else
211  _THROW(_STD range_error, "bad conversion");
212  }
213  }
214  return (_Bstr);
215  }
wide_string::traits_type::int_type int_type
Definition: wstring:37
size_t _Nconv
Definition: wstring:226
Definition: stdexcept:239
byte_string _Berr
Definition: wstring:220
state_type _State
Definition: wstring:222
_STD basic_string< char > byte_string
Definition: wstring:34
bool _Has_state
Definition: wstring:223
bool _Has_berr
Definition: wstring:224
#define _THROW(x, y)
Definition: xstddef:77
_Codecvt * _Pcvt
Definition: wstring:218
#define _CSTD
Definition: yvals.h:570
_Codecvt::state_type state_type
Definition: wstring:36
_FwdIt _Last
Definition: algorithm:1936

Member Data Documentation

template<class _Codecvt , class _Elem = wchar_t>
byte_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::_Berr
private
template<class _Codecvt , class _Elem = wchar_t>
bool stdext::cvt::wstring_convert< _Codecvt, _Elem >::_Has_berr
private
template<class _Codecvt , class _Elem = wchar_t>
bool stdext::cvt::wstring_convert< _Codecvt, _Elem >::_Has_state
private
template<class _Codecvt , class _Elem = wchar_t>
bool stdext::cvt::wstring_convert< _Codecvt, _Elem >::_Has_werr
private
template<class _Codecvt , class _Elem = wchar_t>
_STD locale stdext::cvt::wstring_convert< _Codecvt, _Elem >::_Loc
private
template<class _Codecvt , class _Elem = wchar_t>
size_t stdext::cvt::wstring_convert< _Codecvt, _Elem >::_Nconv
private
template<class _Codecvt , class _Elem = wchar_t>
_Codecvt* stdext::cvt::wstring_convert< _Codecvt, _Elem >::_Pcvt
private
template<class _Codecvt , class _Elem = wchar_t>
state_type stdext::cvt::wstring_convert< _Codecvt, _Elem >::_State
private
template<class _Codecvt , class _Elem = wchar_t>
wide_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::_Werr
private

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