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
 
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)
 

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:220
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:26
bool _Has_berr
Definition: wstring:221
bool _Has_werr
Definition: wstring:222
template<class _Codecvt , class _Elem = wchar_t>
stdext::cvt::wstring_convert< _Codecvt, _Elem >::wstring_convert ( _Codecvt *  _Pcvt_arg)
inline
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:220
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:26
bool _Has_berr
Definition: wstring:221
bool _Has_werr
Definition: wstring:222
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:219
bool _Has_state
Definition: wstring:220
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:26
bool _Has_berr
Definition: wstring:221
bool _Has_werr
Definition: wstring:222
template<class _Codecvt , class _Elem = wchar_t>
stdext::cvt::wstring_convert< _Codecvt, _Elem >::wstring_convert ( const byte_string _Berr_arg)
inline
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:217
bool _Has_state
Definition: wstring:220
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:26
bool _Has_berr
Definition: wstring:221
bool _Has_werr
Definition: wstring:222
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:217
bool _Has_state
Definition: wstring:220
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:26
bool _Has_berr
Definition: wstring:221
wide_string _Werr
Definition: wstring:218
bool _Has_werr
Definition: wstring:222
template<class _Codecvt , class _Elem = wchar_t>
virtual stdext::cvt::wstring_convert< _Codecvt, _Elem >::~wstring_convert ( )
inlinevirtual
74  { // destroy the object
75  }

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:223
_STD locale _Loc
Definition: wstring:216
_Codecvt * _Pcvt
Definition: wstring:215
#define _ADDFAC(loc, pfac)
Definition: xlocale:553
template<class _Codecvt , class _Elem = wchar_t>
size_t stdext::cvt::wstring_convert< _Codecvt, _Elem >::converted ( ) const
inline
78  { // get conversion count
79  return (_Nconv);
80  }
size_t _Nconv
Definition: wstring:223
template<class _Codecvt , class _Elem = wchar_t>
wide_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::from_bytes ( char  _Byte)
inline
88  { // convert a byte to a wide string
89  return (from_bytes(&_Byte, &_Byte + 1));
90  }
wide_string from_bytes(char _Byte)
Definition: wstring:87
template<class _Codecvt , class _Elem = wchar_t>
wide_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::from_bytes ( const char *  _Ptr)
inline
93  { // convert a NTBS to a wide string
94  return (from_bytes(_Ptr, _Ptr + strlen(_Ptr)));
95  }
wide_string from_bytes(char _Byte)
Definition: wstring:87
_Check_return_ size_t __cdecl strlen(_In_z_ const char *_Str)
template<class _Codecvt , class _Elem = wchar_t>
wide_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::from_bytes ( const byte_string _Bstr)
inline
98  { // convert a byte string to a wide string
99  const char *_Ptr = _Bstr.c_str();
100  return (from_bytes(_Ptr, _Ptr + _Bstr.size()));
101  }
wide_string from_bytes(char _Byte)
Definition: wstring:87
template<class _Codecvt , class _Elem = wchar_t>
wide_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::from_bytes ( const char *  _First,
const char *  _Last 
)
inline
104  { // convert byte sequence [_First, _Last) to a wide string
105  static state_type _State0;
106  wide_string _Wbuf, _Wstr;
107  const char *_First_sav = _First;
108 
109  if (!_Has_state)
110  _State = _State0; // reset state if not remembered
111  _Wbuf.append((_CSTD size_t)_BUF_INC, (_Elem)'\0');
112  for (_Nconv = 0; _First != _Last; _Nconv = _First - _First_sav)
113  { // convert one or more bytes
114  _Elem *_Dest = &*_Wbuf.begin();
115  _Elem *_Dnext;
116 
117  switch (_Pcvt->in(_State,
118  _First, _Last, _First,
119  _Dest, _Dest + _Wbuf.size(), _Dnext))
120  { // test result of converting one or more bytes
121  case _Codecvt::partial:
122  case _Codecvt::ok:
123  if (_Dest < _Dnext)
124  _Wstr.append(_Dest, (_CSTD size_t)(_Dnext - _Dest));
125  else if (_Wbuf.size() < _BUF_MAX)
126  _Wbuf.append((_CSTD size_t)_BUF_INC, '\0');
127  else if (_Has_werr)
128  return (_Werr);
129  else
130  _THROW(_STD range_error, "bad conversion");
131  break;
132 
133  case _Codecvt::noconv:
134  for (; _First != _Last; ++_First)
135  _Wstr.append((_CSTD size_t)1,
136  (_Elem)(unsigned char)*_First);
137  break; // no conversion, just copy code values
138 
139  default:
140  if (_Has_werr)
141  return (_Werr);
142  else
143  _THROW(_STD range_error, "bad conversion");
144  }
145  }
146  return (_Wstr);
147  }
size_t _Nconv
Definition: wstring:223
Definition: stdexcept:249
state_type _State
Definition: wstring:219
bool _Has_state
Definition: wstring:220
wide_string _Werr
Definition: wstring:218
bool _Has_werr
Definition: wstring:222
#define _THROW(x, y)
Definition: xstddef:78
_Codecvt * _Pcvt
Definition: wstring:215
_STD basic_string< _Elem > wide_string
Definition: wstring:35
#define _CSTD
Definition: yvals.h:559
_Codecvt::state_type state_type
Definition: wstring:36
_FwdIt _Last
Definition: algorithm:1936
template<class _Codecvt , class _Elem = wchar_t>
state_type stdext::cvt::wstring_convert< _Codecvt, _Elem >::state ( ) const
inline
83  { // get state
84  return (_State);
85  }
state_type _State
Definition: wstring:219
template<class _Codecvt , class _Elem = wchar_t>
byte_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::to_bytes ( _Elem  _Char)
inline
150  { // convert a wide char to a byte string
151  return (to_bytes(&_Char, &_Char + 1));
152  }
byte_string to_bytes(_Elem _Char)
Definition: wstring:149
template<class _Codecvt , class _Elem = wchar_t>
byte_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::to_bytes ( const _Elem *  _Wptr)
inline
155  { // convert a NTWCS to a byte string
156  const _Elem *_Next = _Wptr;
157  for (; (int_type)*_Next != 0; ++_Next)
158  ;
159  return (to_bytes(_Wptr, _Next));
160  }
wide_string::traits_type::int_type int_type
Definition: wstring:37
byte_string to_bytes(_Elem _Char)
Definition: wstring:149
template<class _Codecvt , class _Elem = wchar_t>
byte_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::to_bytes ( const wide_string _Wstr)
inline
163  { // convert a wide string to a byte string
164  const _Elem *_Wptr = _Wstr.c_str();
165  return (to_bytes(_Wptr, _Wptr + _Wstr.size()));
166  }
byte_string to_bytes(_Elem _Char)
Definition: wstring:149
template<class _Codecvt , class _Elem = wchar_t>
byte_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::to_bytes ( const _Elem *  _First,
const _Elem *  _Last 
)
inline
169  { // convert wide sequence [_First, _Last) to a byte string
170  static state_type _State0;
171  byte_string _Bbuf, _Bstr;
172  const _Elem *_First_sav = _First;
173 
174  if (!_Has_state)
175  _State = _State0; // reset state if not remembered
176  _Bbuf.append((_CSTD size_t)_BUF_INC, '\0');
177  for (_Nconv = 0; _First != _Last; _Nconv = _First - _First_sav)
178  { // convert one or more wide chars
179  char *_Dest = &*_Bbuf.begin();
180  char *_Dnext;
181 
182  switch (_Pcvt->out(_State,
183  _First, _Last, _First,
184  _Dest, _Dest + _Bbuf.size(), _Dnext))
185  { // test result of converting one or more wide chars
186  case _Codecvt::partial:
187  case _Codecvt::ok:
188  if (_Dest < _Dnext)
189  _Bstr.append(_Dest, (_CSTD size_t)(_Dnext - _Dest));
190  else if (_Bbuf.size() < _BUF_MAX)
191  _Bbuf.append((_CSTD size_t)_BUF_INC, '\0');
192  else if (_Has_berr)
193  return (_Berr);
194  else
195  _THROW(_STD range_error, "bad conversion");
196  break;
197 
198  case _Codecvt::noconv:
199  for (; _First != _Last; ++_First)
200  _Bstr.append((_CSTD size_t)1,
201  (char)(int_type)*_First);
202  break; // no conversion, just copy code values
203 
204  default:
205  if (_Has_berr)
206  return (_Berr);
207  else
208  _THROW(_STD range_error, "bad conversion");
209  }
210  }
211  return (_Bstr);
212  }
wide_string::traits_type::int_type int_type
Definition: wstring:37
size_t _Nconv
Definition: wstring:223
Definition: stdexcept:249
byte_string _Berr
Definition: wstring:217
state_type _State
Definition: wstring:219
_STD basic_string< char > byte_string
Definition: wstring:34
bool _Has_state
Definition: wstring:220
bool _Has_berr
Definition: wstring:221
#define _THROW(x, y)
Definition: xstddef:78
_Codecvt * _Pcvt
Definition: wstring:215
#define _CSTD
Definition: yvals.h:559
_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: