Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygen_codecvt.h
Go to the documentation of this file.
00001 /* 00002 * Copyright (c) 1999 00003 * Silicon Graphics Computer Systems, Inc. 00004 * 00005 * Copyright (c) 1999 00006 * Boris Fomitchev 00007 * 00008 * This material is provided "as is", with absolutely no warranty expressed 00009 * or implied. Any use is at your own risk. 00010 * 00011 * Permission to use or copy this software for any purpose is hereby granted 00012 * without fee, provided the above notices are retained on all copies. 00013 * Permission to modify the code and to distribute modified code is granted, 00014 * provided the above notices are retained, and a notice that the code was 00015 * modified is included with the above copyright notice. 00016 * 00017 */ 00018 // WARNING: This is an internal header file, included by other C++ 00019 // standard library headers. You should not attempt to use this header 00020 // file directly. 00021 00022 00023 #ifndef _STLP_INTERNAL_CODECVT_H 00024 #define _STLP_INTERNAL_CODECVT_H 00025 00026 #ifndef _STLP_C_LOCALE_H 00027 # include <stl/c_locale.h> 00028 #endif 00029 00030 #ifndef _STLP_INTERNAL_LOCALE_H 00031 # include <stl/_locale.h> 00032 #endif 00033 00034 #ifndef _STLP_INTERNAL_ALGOBASE_H 00035 # include <stl/_algobase.h> 00036 #endif 00037 00038 _STLP_BEGIN_NAMESPACE 00039 00040 class _STLP_CLASS_DECLSPEC codecvt_base { 00041 public: 00042 enum result {ok, partial, error, noconv}; 00043 }; 00044 00045 template <class _InternT, class _ExternT, class _StateT> 00046 class codecvt : public locale::facet, public codecvt_base { 00047 public: 00048 typedef _InternT intern_type; 00049 typedef _ExternT extern_type; 00050 typedef _StateT state_type; 00051 00052 #if defined (_STLP_MSVC) && (_STLP_MSVC < 1300) 00053 /* For the moment VC6 do not support this facet default implementation 00054 * because of the static locale::id instance. When VC6 see this definition 00055 * it goes crasy with locale::id static instances and all the has_facet tests 00056 * unit tests are failing. 00057 */ 00058 }; 00059 #else 00060 explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {} 00061 00062 result out(state_type& __state, 00063 const intern_type* __from, 00064 const intern_type* __from_end, 00065 const intern_type*& __from_next, 00066 extern_type* __to, 00067 extern_type* __to_limit, 00068 extern_type*& __to_next) const { 00069 _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) 00070 _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) 00071 return do_out(__state, 00072 __from, __from_end, __from_next, 00073 __to, __to_limit, __to_next); 00074 } 00075 00076 result unshift(state_type& __state, 00077 extern_type* __to, 00078 extern_type* __to_limit, 00079 extern_type*& __to_next) const { 00080 _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) 00081 return do_unshift(__state, __to, __to_limit, __to_next); 00082 } 00083 00084 result in(state_type& __state, 00085 const extern_type* __from, 00086 const extern_type* __from_end, 00087 const extern_type*& __from_next, 00088 intern_type* __to, 00089 intern_type* __to_limit, 00090 intern_type*& __to_next) const { 00091 _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) 00092 _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) 00093 return do_in(__state, 00094 __from, __from_end, __from_next, 00095 __to, __to_limit, __to_next); 00096 } 00097 00098 int encoding() const _STLP_NOTHROW { return do_encoding(); } 00099 00100 bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); } 00101 00102 int length(state_type& __state, 00103 const extern_type* __from, 00104 const extern_type* __from_end, 00105 size_t __max) const { 00106 _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) 00107 return do_length(__state, __from, __from_end, __max); 00108 } 00109 00110 int max_length() const _STLP_NOTHROW { return do_max_length(); } 00111 00112 static locale::id id; 00113 00114 protected: 00115 ~codecvt() {} 00116 00117 virtual result do_out(state_type&, 00118 const intern_type* __from, 00119 const intern_type*, 00120 const intern_type*& __from_next, 00121 extern_type* __to, 00122 extern_type*, 00123 extern_type*& __to_next) const 00124 { __from_next = __from; __to_next = __to; return noconv; } 00125 00126 virtual result do_in (state_type&, 00127 const extern_type* __from, 00128 const extern_type*, 00129 const extern_type*& __from_next, 00130 intern_type* __to, 00131 intern_type*, 00132 intern_type*& __to_next) const 00133 { __from_next = __from; __to_next = __to; return noconv; } 00134 00135 virtual result do_unshift(state_type&, 00136 extern_type* __to, 00137 extern_type*, 00138 extern_type*& __to_next) const 00139 { __to_next = __to; return noconv; } 00140 00141 virtual int do_encoding() const _STLP_NOTHROW 00142 { return 1; } 00143 00144 virtual bool do_always_noconv() const _STLP_NOTHROW 00145 { return true; } 00146 00147 virtual int do_length(state_type&, 00148 const extern_type* __from, 00149 const extern_type* __end, 00150 size_t __max) const 00151 { return (int)(min) ( __STATIC_CAST(size_t, (__end - __from)), __max); } 00152 00153 virtual int do_max_length() const _STLP_NOTHROW 00154 { return 1; } 00155 00156 private: 00157 codecvt(const codecvt<intern_type, extern_type, state_type>&); 00158 codecvt<intern_type, extern_type, state_type>& operator = (const codecvt<intern_type, extern_type, state_type>&); 00159 }; 00160 00161 # if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) 00162 # if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x590) 00163 template <class _InternT, class _ExternT, class _StateT> 00164 locale::id codecvt<_InternT, _ExternT, _StateT>::id; 00165 # endif 00166 # endif 00167 #endif 00168 00169 template <class _InternT, class _ExternT, class _StateT> 00170 class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> {}; 00171 00172 _STLP_TEMPLATE_NULL 00173 class _STLP_CLASS_DECLSPEC codecvt<char, char, mbstate_t> 00174 : public locale::facet, public codecvt_base { 00175 public: 00176 typedef char intern_type; 00177 typedef char extern_type; 00178 typedef mbstate_t state_type; 00179 00180 explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {} 00181 00182 result out(state_type& __state, 00183 const char* __from, 00184 const char* __from_end, 00185 const char*& __from_next, 00186 char* __to, 00187 char* __to_limit, 00188 char*& __to_next) const { 00189 _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) 00190 _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) 00191 return do_out(__state, 00192 __from, __from_end, __from_next, 00193 __to, __to_limit, __to_next); 00194 } 00195 00196 result unshift(state_type& __state, 00197 char* __to, char* __to_limit, char*& __to_next) const { 00198 _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) 00199 return do_unshift(__state, __to, __to_limit, __to_next); 00200 } 00201 00202 result in(state_type& __state, 00203 const char* __from, 00204 const char* __from_end, 00205 const char*& __from_next, 00206 char* __to, 00207 char* __to_limit, 00208 char*& __to_next) const { 00209 _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) 00210 _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) 00211 return do_in(__state, 00212 __from, __from_end, __from_next, 00213 __to, __to_limit, __to_next); 00214 } 00215 00216 int encoding() const _STLP_NOTHROW { return do_encoding(); } 00217 00218 bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); } 00219 00220 int length(state_type& __state, 00221 const char* __from, const char* __from_end, 00222 size_t __max) const { 00223 _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) 00224 return do_length(__state, __from, __from_end, __max); 00225 } 00226 00227 int max_length() const _STLP_NOTHROW { return do_max_length(); } 00228 00229 static _STLP_STATIC_DECLSPEC locale::id id; 00230 00231 protected: 00232 ~codecvt(); 00233 00234 virtual result do_out(state_type& /* __state */, 00235 const char* __from, 00236 const char* /* __from_end */, 00237 const char*& __from_next, 00238 char* __to, 00239 char* /* __to_limit */, 00240 char*& __to_next) const; 00241 00242 virtual result do_in (state_type& /* __state */ , 00243 const char* __from, 00244 const char* /* __from_end */, 00245 const char*& __from_next, 00246 char* __to, 00247 char* /* __to_end */, 00248 char*& __to_next) const; 00249 00250 virtual result do_unshift(state_type& /* __state */, 00251 char* __to, 00252 char* /* __to_limit */, 00253 char*& __to_next) const; 00254 00255 virtual int do_encoding() const _STLP_NOTHROW; 00256 virtual bool do_always_noconv() const _STLP_NOTHROW; 00257 virtual int do_length(state_type& __state, 00258 const char* __from, 00259 const char* __end, 00260 size_t __max) const; 00261 virtual int do_max_length() const _STLP_NOTHROW; 00262 private: 00263 codecvt(const codecvt<char, char, mbstate_t>&); 00264 codecvt<char, char, mbstate_t>& operator =(const codecvt<char, char, mbstate_t>&); 00265 }; 00266 00267 # ifndef _STLP_NO_WCHAR_T 00268 00269 _STLP_TEMPLATE_NULL 00270 class _STLP_CLASS_DECLSPEC codecvt<wchar_t, char, mbstate_t> 00271 : public locale::facet, public codecvt_base { 00272 public: 00273 typedef wchar_t intern_type; 00274 typedef char extern_type; 00275 typedef mbstate_t state_type; 00276 00277 explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {} 00278 00279 result out(state_type& __state, 00280 const wchar_t* __from, 00281 const wchar_t* __from_end, 00282 const wchar_t*& __from_next, 00283 char* __to, 00284 char* __to_limit, 00285 char*& __to_next) const { 00286 _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) 00287 _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) 00288 return do_out(__state, 00289 __from, __from_end, __from_next, 00290 __to, __to_limit, __to_next); 00291 } 00292 00293 result unshift(state_type& __state, 00294 char* __to, char* __to_limit, char*& __to_next) const { 00295 _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) 00296 return do_unshift(__state, __to, __to_limit, __to_next); 00297 } 00298 00299 result in(state_type& __state, 00300 const char* __from, 00301 const char* __from_end, 00302 const char*& __from_next, 00303 wchar_t* __to, 00304 wchar_t* __to_limit, 00305 wchar_t*& __to_next) const { 00306 _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) 00307 _STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT) 00308 return do_in(__state, 00309 __from, __from_end, __from_next, 00310 __to, __to_limit, __to_next); 00311 } 00312 00313 int encoding() const _STLP_NOTHROW { return do_encoding(); } 00314 00315 bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); } 00316 00317 int length(state_type& __state, 00318 const char* __from, const char* __from_end, 00319 size_t __max) const { 00320 _STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT) 00321 return do_length(__state, __from, __from_end, __max); 00322 } 00323 00324 int max_length() const _STLP_NOTHROW { return do_max_length(); } 00325 00326 static _STLP_STATIC_DECLSPEC locale::id id; 00327 00328 protected: 00329 ~codecvt(); 00330 00331 virtual result do_out(state_type& __state, 00332 const wchar_t* __from, 00333 const wchar_t* __from_end, 00334 const wchar_t*& __from_next, 00335 char* __to, 00336 char* __to_limit, 00337 char*& __to_next) const; 00338 00339 virtual result do_in (state_type& __state, 00340 const char* __from, 00341 const char* __from_end, 00342 const char*& __from_next, 00343 wchar_t* __to, 00344 wchar_t* __to_limit, 00345 wchar_t*& __to_next) const; 00346 00347 virtual result do_unshift(state_type& __state, 00348 char* __to, 00349 char* __to_limit, 00350 char*& __to_next) const; 00351 00352 virtual int do_encoding() const _STLP_NOTHROW; 00353 00354 virtual bool do_always_noconv() const _STLP_NOTHROW; 00355 00356 virtual int do_length(state_type& __state, 00357 const char* __from, 00358 const char* __end, 00359 size_t __max) const; 00360 00361 virtual int do_max_length() const _STLP_NOTHROW; 00362 00363 private: 00364 codecvt(const codecvt<wchar_t, char, mbstate_t>&); 00365 codecvt<wchar_t, char, mbstate_t>& operator = (const codecvt<wchar_t, char, mbstate_t>&); 00366 }; 00367 00368 # endif 00369 00370 _STLP_TEMPLATE_NULL 00371 class _STLP_CLASS_DECLSPEC codecvt_byname<char, char, mbstate_t> 00372 : public codecvt<char, char, mbstate_t> { 00373 public: 00374 explicit codecvt_byname(const char* __name, size_t __refs = 0); 00375 ~codecvt_byname(); 00376 private: 00377 codecvt_byname(const codecvt_byname<char, char, mbstate_t>&); 00378 codecvt_byname<char, char, mbstate_t>& operator =(const codecvt_byname<char, char, mbstate_t>&); 00379 }; 00380 00381 # ifndef _STLP_NO_WCHAR_T 00382 _STLP_TEMPLATE_NULL 00383 class _STLP_CLASS_DECLSPEC codecvt_byname<wchar_t, char, mbstate_t> 00384 : public codecvt<wchar_t, char, mbstate_t> { 00385 friend class _Locale_impl; 00386 public: 00387 explicit codecvt_byname(const char * __name, size_t __refs = 0); 00388 00389 protected: 00390 ~codecvt_byname(); 00391 00392 virtual result do_out(state_type& __state, 00393 const wchar_t* __from, 00394 const wchar_t* __from_end, 00395 const wchar_t*& __from_next, 00396 char* __to, 00397 char* __to_limit, 00398 char*& __to_next) const; 00399 00400 virtual result do_in (state_type& __state, 00401 const char* __from, 00402 const char* __from_end, 00403 const char*& __from_next, 00404 wchar_t* __to, 00405 wchar_t* __to_limit, 00406 wchar_t*& __to_next) const; 00407 00408 virtual result do_unshift(state_type& __state, 00409 char* __to, 00410 char* __to_limit, 00411 char*& __to_next) const; 00412 00413 virtual int do_encoding() const _STLP_NOTHROW; 00414 00415 virtual bool do_always_noconv() const _STLP_NOTHROW; 00416 00417 virtual int do_length(state_type& __state, 00418 const char* __from, 00419 const char* __end, 00420 size_t __max) const; 00421 00422 virtual int do_max_length() const _STLP_NOTHROW; 00423 00424 private: 00425 codecvt_byname(_Locale_codecvt* __cvt) 00426 : _M_codecvt(__cvt) {} 00427 00428 codecvt_byname(const codecvt_byname<wchar_t, char, mbstate_t>&); 00429 codecvt_byname<wchar_t, char, mbstate_t>& operator =(const codecvt_byname<wchar_t, char, mbstate_t>&); 00430 _Locale_codecvt* _M_codecvt; 00431 }; 00432 00433 # endif 00434 00435 _STLP_END_NAMESPACE 00436 00437 #endif /* _STLP_INTERNAL_CODECVT_H */ 00438 00439 // Local Variables: 00440 // mode:C++ 00441 // End: 00442 Generated on Sun May 27 2012 04:28:51 for ReactOS by
1.7.6.1
|