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< charbyte_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 
25 {_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
41  : _Has_berr(false), _Has_werr(false), _Has_state(false)
42  { // construct with no error strings
43  _Init();
44  }
bool _Has_state
Definition: wstring:224
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:27
bool _Has_berr
Definition: wstring:225
bool _Has_werr
Definition: wstring:226
template<class _Codecvt , class _Elem = wchar_t>
stdext::cvt::wstring_convert< _Codecvt, _Elem >::wstring_convert ( _Codecvt *  _Pcvt_arg)
inlineexplicit
47  : _Has_berr(false), _Has_werr(false), _Has_state(false)
48  { // construct with no error strings and codecvt
49  _Init(_Pcvt_arg);
50  }
bool _Has_state
Definition: wstring:224
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:27
bool _Has_berr
Definition: wstring:225
bool _Has_werr
Definition: wstring:226
template<class _Codecvt , class _Elem = wchar_t>
stdext::cvt::wstring_convert< _Codecvt, _Elem >::wstring_convert ( _Codecvt *  _Pcvt_arg,
state_type  _State_arg 
)
inline
53  : _Has_berr(false), _Has_werr(false), _Has_state(true)
54  { // construct with no error strings, codecvt, and state
55  _Init(_Pcvt_arg);
56  _State = _State_arg;
57  }
state_type _State
Definition: wstring:223
bool _Has_state
Definition: wstring:224
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:27
bool _Has_berr
Definition: wstring:225
bool _Has_werr
Definition: wstring:226
template<class _Codecvt , class _Elem = wchar_t>
stdext::cvt::wstring_convert< _Codecvt, _Elem >::wstring_convert ( const byte_string _Berr_arg)
inlineexplicit
60  : _Has_berr(true), _Has_werr(false), _Has_state(false),
61  _Berr(_Berr_arg)
62  { // construct with byte error string
63  _Init();
64  }
byte_string _Berr
Definition: wstring:221
bool _Has_state
Definition: wstring:224
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:27
bool _Has_berr
Definition: wstring:225
bool _Has_werr
Definition: wstring:226
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
68  : _Has_berr(true), _Has_werr(true), _Has_state(false),
69  _Berr(_Berr_arg), _Werr(_Werr_arg)
70  { // construct with byte and wide error strings
71  _Init();
72  }
byte_string _Berr
Definition: wstring:221
bool _Has_state
Definition: wstring:224
void _Init(_Codecvt *_Pcvt_arg=new _Codecvt)
Definition: wstring:27
bool _Has_berr
Definition: wstring:225
wide_string _Werr
Definition: wstring:222
bool _Has_werr
Definition: wstring:226
template<class _Codecvt , class _Elem = wchar_t>
virtual stdext::cvt::wstring_convert< _Codecvt, _Elem >::~wstring_convert ( )
inlinevirtual
75  { // destroy the object
76  }
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
28  { // initialize the object
29  _Pcvt = _Pcvt_arg;
31  _Nconv = 0;
32  }
size_t _Nconv
Definition: wstring:227
_STD locale _Loc
Definition: wstring:220
_Codecvt * _Pcvt
Definition: wstring:219
#define _ADDFAC(loc, pfac)
Definition: xlocale:497
template<class _Codecvt , class _Elem = wchar_t>
size_t stdext::cvt::wstring_convert< _Codecvt, _Elem >::converted ( ) const
inline
82  { // get conversion count
83  return (_Nconv);
84  }
size_t _Nconv
Definition: wstring:227
template<class _Codecvt , class _Elem = wchar_t>
wide_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::from_bytes ( char  _Byte)
inline
92  { // convert a byte to a wide string
93  return (from_bytes(&_Byte, &_Byte + 1));
94  }
wide_string from_bytes(char _Byte)
Definition: wstring:91
template<class _Codecvt , class _Elem = wchar_t>
wide_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::from_bytes ( const char _Ptr)
inline
97  { // convert a NTBS to a wide string
98  return (from_bytes(_Ptr, _Ptr + _CSTD strlen(_Ptr)));
99  }
_Check_return_ size_t __cdecl strlen(_In_z_ char const *_Str)
wide_string from_bytes(char _Byte)
Definition: wstring:91
#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
102  { // convert a byte string to a wide string
103  const char *_Ptr = _Bstr.c_str();
104  return (from_bytes(_Ptr, _Ptr + _Bstr.size()));
105  }
wide_string from_bytes(char _Byte)
Definition: wstring:91
template<class _Codecvt , class _Elem = wchar_t>
wide_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::from_bytes ( const char _First,
const char _Last 
)
inline
108  { // convert byte sequence [_First, _Last) to a wide string
109  static state_type _State0;
110  wide_string _Wbuf, _Wstr;
111  const char *_First_sav = _First;
112 
113  if (!_Has_state)
114  _State = _State0; // reset state if not remembered
115  _Wbuf.append((_CSTD size_t)_BUF_INC, (_Elem)'\0');
116  for (_Nconv = 0; _First != _Last; _Nconv = _First - _First_sav)
117  { // convert one or more bytes
118  _Elem *_Dest = &*_Wbuf.begin();
119  _Elem *_Dnext;
120 
121  switch (_Pcvt->in(_State,
122  _First, _Last, _First,
123  _Dest, _Dest + _Wbuf.size(), _Dnext))
124  { // test result of converting one or more bytes
125  case _Codecvt::partial:
126  case _Codecvt::ok:
127  if (_Dest < _Dnext)
128  _Wstr.append(_Dest, (_CSTD size_t)(_Dnext - _Dest));
129  else if (_Wbuf.size() < _BUF_MAX)
130  _Wbuf.append((_CSTD size_t)_BUF_INC, '\0');
131  else if (_Has_werr)
132  return (_Werr);
133  else
134  _THROW(_STD range_error, "bad conversion");
135  break;
136 
137  case _Codecvt::noconv:
138  for (; _First != _Last; ++_First)
139  _Wstr.append((_CSTD size_t)1,
140  (_Elem)(unsigned char)*_First);
141  break; // no conversion, just copy code values
142 
143  default:
144  if (_Has_werr)
145  return (_Werr);
146  else
147  _THROW(_STD range_error, "bad conversion");
148  }
149  }
150  return (_Wstr);
151  }
size_t _Nconv
Definition: wstring:227
Definition: stdexcept:240
state_type _State
Definition: wstring:223
unsigned _Dest
Definition: mbstring.h:107
bool _Has_state
Definition: wstring:224
wide_string _Werr
Definition: wstring:222
bool _Has_werr
Definition: wstring:226
#define _THROW(x, y)
Definition: xstddef:50
_Codecvt * _Pcvt
Definition: wstring:219
_STD basic_string< _Elem > wide_string
Definition: wstring:36
#define _CSTD
Definition: yvals.h:570
_Codecvt::state_type state_type
Definition: wstring:37
_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
87  { // get state
88  return (_State);
89  }
state_type _State
Definition: wstring:223
template<class _Codecvt , class _Elem = wchar_t>
byte_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::to_bytes ( _Elem  _Char)
inline
154  { // convert a wide char to a byte string
155  return (to_bytes(&_Char, &_Char + 1));
156  }
byte_string to_bytes(_Elem _Char)
Definition: wstring:153
template<class _Codecvt , class _Elem = wchar_t>
byte_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::to_bytes ( const _Elem *  _Wptr)
inline
159  { // convert a NTWCS to a byte string
160  const _Elem *_Next = _Wptr;
161  for (; (int_type)*_Next != 0; ++_Next)
162  ;
163  return (to_bytes(_Wptr, _Next));
164  }
wide_string::traits_type::int_type int_type
Definition: wstring:38
byte_string to_bytes(_Elem _Char)
Definition: wstring:153
template<class _Codecvt , class _Elem = wchar_t>
byte_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::to_bytes ( const wide_string _Wstr)
inline
167  { // convert a wide string to a byte string
168  const _Elem *_Wptr = _Wstr.c_str();
169  return (to_bytes(_Wptr, _Wptr + _Wstr.size()));
170  }
byte_string to_bytes(_Elem _Char)
Definition: wstring:153
template<class _Codecvt , class _Elem = wchar_t>
byte_string stdext::cvt::wstring_convert< _Codecvt, _Elem >::to_bytes ( const _Elem *  _First,
const _Elem *  _Last 
)
inline
173  { // convert wide sequence [_First, _Last) to a byte string
174  static state_type _State0;
175  byte_string _Bbuf, _Bstr;
176  const _Elem *_First_sav = _First;
177 
178  if (!_Has_state)
179  _State = _State0; // reset state if not remembered
180  _Bbuf.append((_CSTD size_t)_BUF_INC, '\0');
181  for (_Nconv = 0; _First != _Last; _Nconv = _First - _First_sav)
182  { // convert one or more wide chars
183  char *_Dest = &*_Bbuf.begin();
184  char *_Dnext;
185 
186  switch (_Pcvt->out(_State,
187  _First, _Last, _First,
188  _Dest, _Dest + _Bbuf.size(), _Dnext))
189  { // test result of converting one or more wide chars
190  case _Codecvt::partial:
191  case _Codecvt::ok:
192  if (_Dest < _Dnext)
193  _Bstr.append(_Dest, (_CSTD size_t)(_Dnext - _Dest));
194  else if (_Bbuf.size() < _BUF_MAX)
195  _Bbuf.append((_CSTD size_t)_BUF_INC, '\0');
196  else if (_Has_berr)
197  return (_Berr);
198  else
199  _THROW(_STD range_error, "bad conversion");
200  break;
201 
202  case _Codecvt::noconv:
203  for (; _First != _Last; ++_First)
204  _Bstr.append((_CSTD size_t)1,
205  (char)(int_type)*_First);
206  break; // no conversion, just copy code values
207 
208  default:
209  if (_Has_berr)
210  return (_Berr);
211  else
212  _THROW(_STD range_error, "bad conversion");
213  }
214  }
215  return (_Bstr);
216  }
wide_string::traits_type::int_type int_type
Definition: wstring:38
size_t _Nconv
Definition: wstring:227
Definition: stdexcept:240
byte_string _Berr
Definition: wstring:221
state_type _State
Definition: wstring:223
unsigned _Dest
Definition: mbstring.h:107
_STD basic_string< char > byte_string
Definition: wstring:35
bool _Has_state
Definition: wstring:224
bool _Has_berr
Definition: wstring:225
#define _THROW(x, y)
Definition: xstddef:50
_Codecvt * _Pcvt
Definition: wstring:219
#define _CSTD
Definition: yvals.h:570
_Codecvt::state_type state_type
Definition: wstring:37
_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: