32#ifndef _RWSTD_LOC_CODECVT_H_INCLUDED
33#define _RWSTD_LOC_CODECVT_H_INCLUDED
53 enum result { ok, partial, error, noconv };
58template <
class _InternT,
class _ExternT,
class _StateT>
62#ifndef _RWSTD_NO_EXT_CODECVT_PRIMARY
65template <
class _InternT,
class _ExternT,
class _StateT>
66class codecvt:
public _RW::__rw_facet,
70 typedef _InternT intern_type;
71 typedef _ExternT extern_type;
72 typedef _StateT state_type;
84 const intern_type*,
const intern_type*,
const intern_type*&,
85 extern_type*, extern_type*, extern_type*&)
const {
86 return sizeof (intern_type) ==
sizeof (extern_type) ? noconv : error;
91 const extern_type*,
const extern_type*,
const extern_type*&,
92 intern_type*, intern_type*, intern_type*&)
const {
93 return sizeof (intern_type) ==
sizeof (extern_type) ? noconv : error;
97 do_unshift (state_type&, extern_type*, extern_type*, extern_type*&)
const {
98 return sizeof (intern_type) ==
sizeof (extern_type) ? noconv : error;
106 return sizeof (intern_type) ==
sizeof (extern_type);
110 return _RWSTD_INT_MAX;
115 const extern_type*,
const extern_type*, _RWSTD_SIZE_T)
const {
116 return _RWSTD_INT_MAX;
121 explicit codecvt (_RWSTD_SIZE_T __ref = 0): _RW::__rw_facet (__ref) { }
127 const intern_type* __from,
const intern_type* __from_end,
128 const intern_type*& __from_next,
129 extern_type* __to, extern_type* __to_limit,
130 extern_type*& __to_next)
const {
131 return do_out(__state,__from,__from_end,__from_next,
132 __to,__to_limit,__to_next);
136 result unshift (state_type& __state, extern_type* __to,
137 extern_type* __to_limit, extern_type*& __to_next)
const {
138 return do_unshift (__state,__to,__to_limit,__to_next);
142 result in (state_type& __state,
const extern_type* __from,
143 const extern_type* __from_end,
const extern_type*& __from_next,
144 intern_type* __to, intern_type* __to_limit,
145 intern_type*& __to_next)
const {
146 return do_in (__state,__from,__from_end,__from_next,
147 __to,__to_limit,__to_next);
151 bool always_noconv ()
const _THROWS (()) {
156 int encoding ()
const _THROWS (()) {
161 int length (state_type& __state,
const extern_type* __from,
162 const extern_type* __end, _RWSTD_SIZE_T __maxlen)
const {
163 return do_length (__state, __from, __end, __maxlen);
167 int max_length()
const _THROWS (()) {
171 static _RW::__rw_facet_id id;
182 :
public _RW::__rw_facet,
187 typedef char extern_type;
188 typedef char intern_type;
191 explicit codecvt (_RWSTD_SIZE_T = 0);
196 const intern_type *__from,
const intern_type* __from_end,
197 const intern_type *&__from_next,
198 extern_type* __to, extern_type* __to_limit,
199 extern_type *&__to_next)
const {
200 return do_out (__state, __from, __from_end, __from_next,
201 __to, __to_limit, __to_next);
204 result unshift (state_type &__state,
205 extern_type *__to, extern_type *__to_limit,
206 extern_type*& __to_next)
const {
207 return do_unshift (__state, __to, __to_limit, __to_next);
211 const extern_type *__from,
const extern_type *__from_end,
212 const extern_type *&__from_next,
213 intern_type *__to, intern_type *__to_limit,
214 intern_type *&__to_next)
const {
215 return do_in (__state, __from, __from_end, __from_next,
216 __to, __to_limit, __to_next);
219 int encoding ()
const _THROWS (()) {
223 bool always_noconv ()
const _THROWS (());
226 int length (state_type &__state,
const extern_type *__from,
227 const extern_type *__end, _RWSTD_SIZE_T __maxlen)
const {
228 return do_length (__state, __from, __end, __maxlen);
231 int max_length ()
const _THROWS (()) {
235 static _RW::__rw_facet_id id;
241 const intern_type*,
const intern_type*,
const intern_type*&,
242 extern_type*, extern_type*, extern_type*&)
const;
246 const extern_type*,
const extern_type*,
const extern_type*&,
247 intern_type*, intern_type*, intern_type*&)
const;
252 extern_type*, extern_type*, extern_type*&)
const;
261 const extern_type*,
const extern_type*, _RWSTD_SIZE_T)
const;
267 int _C_always_noconv;
272codecvt<char, char, _RWSTD_MBSTATE_T>::
273always_noconv ()
const _THROWS (())
276 if (_C_always_noconv < 0) {
279 typedef codecvt<char, char, _RWSTD_MBSTATE_T> _CodeCvt;
286 return 1 == _C_always_noconv;
290#ifndef _RWSTD_NO_WCHAR_T
297 :
public _RW::__rw_facet,
302 typedef wchar_t intern_type;
303 typedef char extern_type;
309 do_out (state_type&,
const intern_type*,
const intern_type*,
311 extern_type*, extern_type*, extern_type*&)
const;
315 const extern_type*,
const extern_type*,
const extern_type*&,
316 intern_type*, intern_type*, intern_type*&)
const;
320 do_unshift (state_type&, extern_type*, extern_type*, extern_type*&)
const;
329 const extern_type*,
const extern_type*, _RWSTD_SIZE_T)
const;
335 explicit codecvt (_RWSTD_SIZE_T = 0);
340 const intern_type *__from,
const intern_type *__from_end,
341 const intern_type *&__from_next,
342 extern_type *__to, extern_type* __to_limit,
343 extern_type *& __to_next)
const {
344 return do_out (__state, __from, __from_end, __from_next, __to,
345 __to_limit, __to_next);
348 result unshift (state_type &__state,
349 extern_type *__to, extern_type *__to_limit,
350 extern_type *&__to_next)
const {
351 return do_unshift (__state, __to, __to_limit, __to_next);
355 const extern_type *__from,
const extern_type *__from_end,
356 const extern_type *&__from_next,
357 intern_type *__to, intern_type *__to_limit,
358 intern_type *&__to_next)
const {
359 return do_in (__state, __from, __from_end, __from_next,
360 __to, __to_limit, __to_next);
363 int encoding ()
const _THROWS (()) {
367 bool always_noconv ()
const _THROWS (()) {
372 int length (state_type &__state,
373 const extern_type *__from,
const extern_type *__end,
374 _RWSTD_SIZE_T __maxlen)
const {
375 return do_length (__state, __from, __end, __maxlen);
378 int max_length ()
const _THROWS (()) {
382 static _RW::__rw_facet_id id;
390template <
class _InternT,
class _ExternT,
class _StateT>
391class codecvt_byname:
public codecvt<_InternT, _ExternT, _StateT>
393 char _C_namebuf [32];
397 typedef _InternT intern_type;
398 typedef _ExternT extern_type;
399 typedef _StateT state_type;
401 explicit codecvt_byname (
const char *__name, _RWSTD_SIZE_T __ref = 0)
402 : codecvt <_InternT, _ExternT, _StateT> (__ref) {
403 this->_C_set_name (__name, _C_namebuf,
sizeof _C_namebuf);
412 :
public codecvt<char, char, _RWSTD_MBSTATE_T>
414 char _C_namebuf [32];
418 explicit codecvt_byname (
const char*, _RWSTD_SIZE_T = 0);
425#ifndef _RWSTD_NO_WCHAR_T
429 :
public codecvt<wchar_t, char, _RWSTD_MBSTATE_T>
431 char _C_namebuf [32];
437 explicit codecvt_byname (
const char*, _RWSTD_SIZE_T = 0);
443 virtual codecvt_base::result
445 const intern_type*,
const intern_type*,
const intern_type*&,
446 extern_type*, extern_type*, extern_type*&)
const;
448 virtual codecvt_base::result
450 const extern_type*,
const extern_type*,
const extern_type*&,
451 intern_type*, intern_type*, intern_type*&)
const;
454 virtual codecvt_base::result
456 extern_type*, extern_type*, extern_type*&)
const;
462 do_length (state_type&,
const extern_type*,
const extern_type*,
463 _RWSTD_SIZE_T)
const;
475#if _RWSTD_DEFINE_TEMPLATE (_CODECVT)
#define _RWSTD_SPECIALIZED_CLASS
#define _RWSTD_NAMESPACE(name)
#define _RWSTD_ATTRIBUTE_NOTHROW
#define _RWSTD_CONST_CAST(T, x)