00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef _CPP_BITS_CODECVT_H
00042 #define _CPP_BITS_CODECVT_H 1
00043
00044 #pragma GCC system_header
00045
00046
00047 class codecvt_base
00048 {
00049 public:
00050 enum result
00051 {
00052 ok,
00053 partial,
00054 error,
00055 noconv
00056 };
00057 };
00058
00059
00060
00061
00062
00063 template<typename _InternT, typename _ExternT, typename _StateT>
00064 class __codecvt_abstract_base
00065 : public locale::facet, public codecvt_base
00066 {
00067 public:
00068
00069 typedef codecvt_base::result result;
00070 typedef _InternT intern_type;
00071 typedef _ExternT extern_type;
00072 typedef _StateT state_type;
00073
00074
00075 result
00076 out(state_type& __state, const intern_type* __from,
00077 const intern_type* __from_end, const intern_type*& __from_next,
00078 extern_type* __to, extern_type* __to_end,
00079 extern_type*& __to_next) const
00080 {
00081 return this->do_out(__state, __from, __from_end, __from_next,
00082 __to, __to_end, __to_next);
00083 }
00084
00085 result
00086 unshift(state_type& __state, extern_type* __to, extern_type* __to_end,
00087 extern_type*& __to_next) const
00088 { return this->do_unshift(__state, __to,__to_end,__to_next); }
00089
00090 result
00091 in(state_type& __state, const extern_type* __from,
00092 const extern_type* __from_end, const extern_type*& __from_next,
00093 intern_type* __to, intern_type* __to_end,
00094 intern_type*& __to_next) const
00095 {
00096 return this->do_in(__state, __from, __from_end, __from_next,
00097 __to, __to_end, __to_next);
00098 }
00099
00100 int
00101 encoding() const throw()
00102 { return this->do_encoding(); }
00103
00104 bool
00105 always_noconv() const throw()
00106 { return this->do_always_noconv(); }
00107
00108 int
00109 length(const state_type& __state, const extern_type* __from,
00110 const extern_type* __end, size_t __max) const
00111 { return this->do_length(__state, __from, __end, __max); }
00112
00113 int
00114 max_length() const throw()
00115 { return this->do_max_length(); }
00116
00117 protected:
00118 explicit
00119 __codecvt_abstract_base(size_t __refs = 0) : locale::facet(__refs) { }
00120
00121 virtual
00122 ~__codecvt_abstract_base() { }
00123
00124 virtual result
00125 do_out(state_type& __state, const intern_type* __from,
00126 const intern_type* __from_end, const intern_type*& __from_next,
00127 extern_type* __to, extern_type* __to_end,
00128 extern_type*& __to_next) const = 0;
00129
00130 virtual result
00131 do_unshift(state_type& __state, extern_type* __to,
00132 extern_type* __to_end, extern_type*& __to_next) const = 0;
00133
00134 virtual result
00135 do_in(state_type& __state, const extern_type* __from,
00136 const extern_type* __from_end, const extern_type*& __from_next,
00137 intern_type* __to, intern_type* __to_end,
00138 intern_type*& __to_next) const = 0;
00139
00140 virtual int
00141 do_encoding() const throw() = 0;
00142
00143 virtual bool
00144 do_always_noconv() const throw() = 0;
00145
00146 virtual int
00147 do_length(const state_type&, const extern_type* __from,
00148 const extern_type* __end, size_t __max) const = 0;
00149
00150 virtual int
00151 do_max_length() const throw() = 0;
00152 };
00153
00154
00155
00156 template<typename _InternT, typename _ExternT, typename _StateT>
00157 class codecvt
00158 : public __codecvt_abstract_base<_InternT, _ExternT, _StateT>
00159 {
00160 public:
00161
00162 typedef codecvt_base::result result;
00163 typedef _InternT intern_type;
00164 typedef _ExternT extern_type;
00165 typedef _StateT state_type;
00166
00167 public:
00168 static locale::id id;
00169
00170 explicit
00171 codecvt(size_t __refs = 0)
00172 : __codecvt_abstract_base<_InternT, _ExternT, _StateT> (__refs) { }
00173
00174 protected:
00175 virtual
00176 ~codecvt() { }
00177
00178 virtual result
00179 do_out(state_type& __state, const intern_type* __from,
00180 const intern_type* __from_end, const intern_type*& __from_next,
00181 extern_type* __to, extern_type* __to_end,
00182 extern_type*& __to_next) const;
00183
00184 virtual result
00185 do_unshift(state_type& __state, extern_type* __to,
00186 extern_type* __to_end, extern_type*& __to_next) const;
00187
00188 virtual result
00189 do_in(state_type& __state, const extern_type* __from,
00190 const extern_type* __from_end, const extern_type*& __from_next,
00191 intern_type* __to, intern_type* __to_end,
00192 intern_type*& __to_next) const;
00193
00194 virtual int
00195 do_encoding() const throw();
00196
00197 virtual bool
00198 do_always_noconv() const throw();
00199
00200 virtual int
00201 do_length(const state_type&, const extern_type* __from,
00202 const extern_type* __end, size_t __max) const;
00203
00204 virtual int
00205 do_max_length() const throw();
00206 };
00207
00208 template<typename _InternT, typename _ExternT, typename _StateT>
00209 locale::id codecvt<_InternT, _ExternT, _StateT>::id;
00210
00211
00212 template<>
00213 class codecvt<char, char, mbstate_t>
00214 : public __codecvt_abstract_base<char, char, mbstate_t>
00215 {
00216 public:
00217
00218 typedef char intern_type;
00219 typedef char extern_type;
00220 typedef mbstate_t state_type;
00221
00222 public:
00223 static locale::id id;
00224
00225 explicit
00226 codecvt(size_t __refs = 0);
00227
00228 protected:
00229 virtual
00230 ~codecvt();
00231
00232 virtual result
00233 do_out(state_type& __state, const intern_type* __from,
00234 const intern_type* __from_end, const intern_type*& __from_next,
00235 extern_type* __to, extern_type* __to_end,
00236 extern_type*& __to_next) const;
00237
00238 virtual result
00239 do_unshift(state_type& __state, extern_type* __to,
00240 extern_type* __to_end, extern_type*& __to_next) const;
00241
00242 virtual result
00243 do_in(state_type& __state, const extern_type* __from,
00244 const extern_type* __from_end, const extern_type*& __from_next,
00245 intern_type* __to, intern_type* __to_end,
00246 intern_type*& __to_next) const;
00247
00248 virtual int
00249 do_encoding() const throw();
00250
00251 virtual bool
00252 do_always_noconv() const throw();
00253
00254 virtual int
00255 do_length(const state_type&, const extern_type* __from,
00256 const extern_type* __end, size_t __max) const;
00257
00258 virtual int
00259 do_max_length() const throw();
00260 };
00261
00262 #ifdef _GLIBCPP_USE_WCHAR_T
00263
00264 template<>
00265 class codecvt<wchar_t, char, mbstate_t>
00266 : public __codecvt_abstract_base<wchar_t, char, mbstate_t>
00267 {
00268 public:
00269
00270 typedef wchar_t intern_type;
00271 typedef char extern_type;
00272 typedef mbstate_t state_type;
00273
00274 public:
00275 static locale::id id;
00276
00277 explicit
00278 codecvt(size_t __refs = 0);
00279
00280 protected:
00281 virtual
00282 ~codecvt();
00283
00284 virtual result
00285 do_out(state_type& __state, const intern_type* __from,
00286 const intern_type* __from_end, const intern_type*& __from_next,
00287 extern_type* __to, extern_type* __to_end,
00288 extern_type*& __to_next) const;
00289
00290 virtual result
00291 do_unshift(state_type& __state,
00292 extern_type* __to, extern_type* __to_end,
00293 extern_type*& __to_next) const;
00294
00295 virtual result
00296 do_in(state_type& __state,
00297 const extern_type* __from, const extern_type* __from_end,
00298 const extern_type*& __from_next,
00299 intern_type* __to, intern_type* __to_end,
00300 intern_type*& __to_next) const;
00301
00302 virtual
00303 int do_encoding() const throw();
00304
00305 virtual
00306 bool do_always_noconv() const throw();
00307
00308 virtual
00309 int do_length(const state_type&, const extern_type* __from,
00310 const extern_type* __end, size_t __max) const;
00311
00312 virtual int
00313 do_max_length() const throw();
00314 };
00315 #endif
00316
00317
00318 template<typename _InternT, typename _ExternT, typename _StateT>
00319 class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT>
00320 {
00321 public:
00322 explicit
00323 codecvt_byname(const char*, size_t __refs = 0)
00324 : codecvt<_InternT, _ExternT, _StateT>(__refs) { }
00325
00326 protected:
00327 virtual
00328 ~codecvt_byname() { }
00329 };
00330
00331
00332
00333 #ifdef _GLIBCPP_USE_WCHAR_T
00334 #include <bits/codecvt_specializations.h>
00335 #endif
00336
00337 #endif // _CPP_BITS_CODECVT_H