_codecvt.h

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 # ifndef _STLP_INTERNAL_LOCALE_H
00030 #  include <stl/_locale.h>
00031 # endif
00032 
00033 _STLP_BEGIN_NAMESPACE
00034 
00035 class _STLP_CLASS_DECLSPEC codecvt_base {
00036 public:
00037   enum result {ok, partial, error, noconv};
00038 };
00039 
00040 template <class _InternT, class _ExternT, class _StateT>
00041 class codecvt {};
00042  
00043 template <class _InternT, class _ExternT, class _StateT>
00044 class codecvt_byname {};
00045 
00046 _STLP_TEMPLATE_NULL
00047 class _STLP_CLASS_DECLSPEC codecvt<char, char, mbstate_t>
00048   : public locale::facet, public codecvt_base 
00049 {
00050   friend class _Locale;
00051 public:
00052   typedef char       intern_type;
00053   typedef char       extern_type;
00054   typedef mbstate_t  state_type;
00055 
00056   explicit codecvt(size_t __refs = 0) : _BaseFacet(__refs) {}
00057 
00058   result out(mbstate_t    __state,
00059              const char*  __from,
00060              const char*  __from_end,
00061              const char*& __from_next,
00062              char*        __to,
00063              char*        __to_limit, 
00064              char*&       __to_next) const {
00065     return do_out(__state, 
00066                   __from, __from_end, __from_next,
00067                   __to,   __to_limit, __to_next);
00068   }
00069 
00070   result unshift(mbstate_t& __state,
00071                  char* __to, char* __to_limit, char*& __to_next) const
00072     { return do_unshift(__state, __to, __to_limit, __to_next); }
00073     
00074   result in(mbstate_t&   __state,
00075             const char*  __from,
00076             const char*  __from_end,  
00077             const char*& __from_next,
00078             char*        __to, 
00079             char*        __to_limit, 
00080             char*&       __to_next) const {
00081     return do_in(__state,
00082                  __from, __from_end, __from_next,
00083                  __to,   __to_limit, __to_next);
00084   }
00085 
00086   int encoding() const _STLP_NOTHROW { return do_encoding(); }
00087 
00088   bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); }
00089 
00090   int length(const mbstate_t& __state,
00091              const char* __from, const char* __end,
00092              size_t __max) const
00093     { return do_length(__state, __from, __end, __max); }
00094   
00095   int max_length() const _STLP_NOTHROW { return do_max_length(); }
00096 
00097   _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
00098 
00099 protected:
00100   ~codecvt();
00101 
00102   virtual result do_out(mbstate_t&   /* __state */,
00103                         const char*  __from,
00104                         const char*  /* __from_end */,
00105                         const char*& __from_next,
00106                         char*        __to,
00107                         char*        /* __to_limit */,
00108                         char*&       __to_next) const;
00109 
00110   virtual result do_in (mbstate_t&   /* __state */ , 
00111                         const char*  __from,
00112                         const char*  /* __from_end */,
00113                         const char*& __from_next,
00114                         char*        __to,
00115                         char*        /* __to_end */,
00116                         char*&       __to_next) const;
00117 
00118   virtual result do_unshift(mbstate_t& /* __state */,
00119                             char*      __to,
00120                             char*      /* __to_limit */,
00121                             char*&     __to_next) const;
00122 
00123   virtual int do_encoding() const _STLP_NOTHROW;
00124   virtual bool do_always_noconv() const _STLP_NOTHROW;
00125   virtual int do_length(const mbstate_t&         __state,
00126                         const  char* __from, 
00127                         const  char* __end,
00128                         size_t __max) const;
00129   virtual int do_max_length() const _STLP_NOTHROW;
00130 private:
00131   codecvt(const codecvt<char, char, mbstate_t>&);
00132   codecvt<char, char, mbstate_t>& operator =(const codecvt<char, char, mbstate_t>&); 
00133 };
00134 
00135 # ifndef _STLP_NO_WCHAR_T
00136  
00137 _STLP_TEMPLATE_NULL
00138 class _STLP_CLASS_DECLSPEC codecvt<wchar_t, char, mbstate_t>
00139   : public locale::facet, public codecvt_base
00140 {
00141   friend class _Locale;
00142 public:
00143   typedef wchar_t    intern_type;
00144   typedef char       extern_type;
00145   typedef mbstate_t  state_type;
00146 
00147   explicit codecvt(size_t __refs = 0) : _BaseFacet(__refs) {}
00148 
00149   result out(mbstate_t       __state,
00150              const wchar_t*  __from,
00151              const wchar_t*  __from_end,
00152              const wchar_t*& __from_next,
00153              char*           __to,
00154              char*           __to_limit,
00155              char*&          __to_next) const {
00156     return do_out(__state,
00157                   __from, __from_end, __from_next, 
00158                   __to,   __to_limit, __to_next);
00159   }
00160 
00161   result unshift(mbstate_t& __state,
00162                  char*  __to, char*  __to_limit, char*& __to_next) const {
00163     return do_unshift(__state, __to, __to_limit, __to_next);
00164   }
00165     
00166   result in(mbstate_t    __state,
00167             const char*  __from,
00168             const char*  __from_end,  
00169             const char*& __from_next,
00170             wchar_t*     __to, 
00171             wchar_t*     __to_limit, 
00172             wchar_t*&    __to_next) const {
00173     return do_in(__state, 
00174                  __from, __from_end, __from_next,
00175                  __to,  __to_limit, __to_next);
00176   }
00177 
00178   int encoding() const _STLP_NOTHROW { return do_encoding(); }
00179 
00180   bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); }
00181 
00182   int length(const mbstate_t&        __state,
00183              const char* __from,
00184              const char* __end,
00185              size_t             __max) const
00186     { return do_length(__state, __from, __end, __max); }
00187   
00188   int max_length() const _STLP_NOTHROW { return do_max_length(); }
00189 
00190   _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
00191 
00192 protected:
00193   ~codecvt();
00194 
00195   virtual result do_out(mbstate_t&         __state,
00196                         const wchar_t*  __from,
00197                         const wchar_t*  __from_end,
00198                         const wchar_t*& __from_next,
00199                         char*        __to,
00200                         char*        __to_limit,
00201                         char*&       __to_next) const;
00202 
00203   virtual result do_in (mbstate_t&         __state,
00204                         const char*  __from,
00205                         const char*  __from_end,
00206                         const char*& __from_next,
00207                         wchar_t*        __to,
00208                         wchar_t*        __to_limit,
00209                         wchar_t*&       __to_next) const;
00210 
00211   virtual result do_unshift(mbstate_t&   __state,
00212                             char*  __to, 
00213                             char*  __to_limit,
00214                             char*& __to_next) const;
00215 
00216   virtual int do_encoding() const _STLP_NOTHROW;
00217 
00218   virtual bool do_always_noconv() const _STLP_NOTHROW;
00219   
00220   virtual int do_length(const mbstate_t& __state,
00221                         const  char* __from, 
00222                         const  char* __end,
00223                         size_t __max) const;
00224 
00225   virtual int do_max_length() const _STLP_NOTHROW;
00226 
00227 private:
00228   codecvt(const codecvt<wchar_t, char, mbstate_t>&);
00229   codecvt<wchar_t, char, mbstate_t>& operator = (const codecvt<wchar_t, char, mbstate_t>&);  
00230 };
00231 
00232 # endif
00233 
00234 _STLP_TEMPLATE_NULL
00235 class _STLP_CLASS_DECLSPEC codecvt_byname<char, char, mbstate_t>
00236   : public codecvt<char, char, mbstate_t> {
00237 public:
00238   explicit codecvt_byname(const char* __name, size_t __refs = 0);
00239   ~codecvt_byname();
00240 private:
00241   codecvt_byname(const codecvt_byname<char, char, mbstate_t>&);
00242   codecvt_byname<char, char, mbstate_t>& operator =(const codecvt_byname<char, char, mbstate_t>&);  
00243 };
00244 
00245 # ifndef _STLP_NO_WCHAR_T
00246 _STLP_TEMPLATE_NULL
00247 class codecvt_byname<wchar_t, char, mbstate_t>
00248   : public codecvt<wchar_t, char, mbstate_t> 
00249 {
00250 public:
00251   explicit codecvt_byname(const char * __name, size_t __refs = 0);    
00252 
00253 protected:
00254   ~codecvt_byname();
00255 
00256   virtual result do_out(mbstate_t&         __state,
00257                         const wchar_t*  __from,
00258                         const wchar_t*  __from_end,
00259                         const wchar_t*& __from_next,
00260                         char*        __to,
00261                         char*        __to_limit,
00262                         char*&       __to_next) const;
00263 
00264   virtual result do_in (mbstate_t&         __state,
00265                         const char*  __from,
00266                         const char*  __from_end,
00267                         const char*& __from_next,
00268                         wchar_t*        __to,
00269                         wchar_t*        __to_limit,
00270                         wchar_t*&       __to_next) const;
00271 
00272   virtual result do_unshift(mbstate_t&   __state,
00273                             char*  __to, 
00274                             char*  __to_limit,
00275                             char*& __to_next) const;
00276 
00277   virtual int do_encoding() const _STLP_NOTHROW;
00278 
00279   virtual bool do_always_noconv() const _STLP_NOTHROW;
00280   
00281   virtual int do_length(const mbstate_t&         __state,
00282                         const  char* __from, 
00283                         const  char* __end,
00284                         size_t __max) const;
00285 
00286   virtual int do_max_length() const _STLP_NOTHROW;
00287 
00288 private:
00289   _Locale_ctype* _M_ctype;
00290   codecvt_byname(const codecvt_byname<wchar_t, char, mbstate_t>&);
00291   codecvt_byname<wchar_t, char, mbstate_t>& operator =(const codecvt_byname<wchar_t, char, mbstate_t>&);  
00292 };
00293 
00294 # endif
00295 
00296 _STLP_END_NAMESPACE
00297 
00298 #endif /* _STLP_INTERNAL_CODECVT_H */
00299 
00300 // Local Variables:
00301 // mode:C++
00302 // End:
00303 

Generated on Mon Jun 5 10:20:45 2006 for Intelligence.kdevelop by  doxygen 1.4.6