codecvt.h

Go to the documentation of this file.
00001 // Locale support (codecvt) -*- C++ -*- 00002 00003 // Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 2, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // You should have received a copy of the GNU General Public License along 00017 // with this library; see the file COPYING. If not, write to the Free 00018 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00019 // USA. 00020 00021 // As a special exception, you may use this file as part of a free software 00022 // library without restriction. Specifically, if other files instantiate 00023 // templates or use macros or inline functions from this file, or you compile 00024 // this file and link it with other files to produce an executable, this 00025 // file does not by itself cause the resulting executable to be covered by 00026 // the GNU General Public License. This exception does not however 00027 // invalidate any other reasons why the executable file might be covered by 00028 // the GNU General Public License. 00029 00030 // 00031 // ISO C++ 14882: 22.2.1.5 Template class codecvt 00032 // 00033 00034 // Written by Benjamin Kosnik <bkoz@cygnus.com> 00035 00036 /** @file codecvt.h 00037 * This is an internal header file, included by other library headers. 00038 * You should not attempt to use it directly. 00039 */ 00040 00041 #ifndef _CPP_BITS_CODECVT_H 00042 #define _CPP_BITS_CODECVT_H 1 00043 00044 #pragma GCC system_header 00045 00046 // 22.2.1.5 Template class codecvt 00047 class codecvt_base 00048 { 00049 public: 00050 enum result 00051 { 00052 ok, 00053 partial, 00054 error, 00055 noconv 00056 }; 00057 }; 00058 00059 // Template class __codecvt_abstract_base 00060 // NB: An abstract base class that fills in the public inlines, so 00061 // that the specializations don't have to re-copy the public 00062 // interface. 00063 template<typename _InternT, typename _ExternT, typename _StateT> 00064 class __codecvt_abstract_base 00065 : public locale::facet, public codecvt_base 00066 { 00067 public: 00068 // Types: 00069 typedef codecvt_base::result result; 00070 typedef _InternT intern_type; 00071 typedef _ExternT extern_type; 00072 typedef _StateT state_type; 00073 00074 // 22.2.1.5.1 codecvt members 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 // 22.2.1.5 Template class codecvt 00155 // NB: Generic, mostly useless implementation. 00156 template<typename _InternT, typename _ExternT, typename _StateT> 00157 class codecvt 00158 : public __codecvt_abstract_base<_InternT, _ExternT, _StateT> 00159 { 00160 public: 00161 // Types: 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 // codecvt<char, char, mbstate_t> required specialization 00212 template<> 00213 class codecvt<char, char, mbstate_t> 00214 : public __codecvt_abstract_base<char, char, mbstate_t> 00215 { 00216 public: 00217 // Types: 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 // codecvt<wchar_t, char, mbstate_t> required specialization 00264 template<> 00265 class codecvt<wchar_t, char, mbstate_t> 00266 : public __codecvt_abstract_base<wchar_t, char, mbstate_t> 00267 { 00268 public: 00269 // Types: 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 //_GLIBCPP_USE_WCHAR_T 00316 00317 // 22.2.1.6 Template class codecvt_byname 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 // Include host and configuration specific partial specializations 00332 // with additional functionality, if possible. 00333 #ifdef _GLIBCPP_USE_WCHAR_T 00334 #include <bits/codecvt_specializations.h> 00335 #endif 00336 00337 #endif // _CPP_BITS_CODECVT_H

Generated on Sun Sep 19 16:33:45 2004 for libstdc++-v3 Source by doxygen 1.3.8