epoc32/include/stdapis/stlport/stl/_codecvt.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     3  *
     4  * Copyright (c) 1999
     5  * Silicon Graphics Computer Systems, Inc.
     6  *
     7  * Copyright (c) 1999 
     8  * Boris Fomitchev
     9  *
    10  * This material is provided "as is", with absolutely no warranty expressed
    11  * or implied. Any use is at your own risk.
    12  *
    13  * Permission to use or copy this software for any purpose is hereby granted 
    14  * without fee, provided the above notices are retained on all copies.
    15  * Permission to modify the code and to distribute modified code is granted,
    16  * provided the above notices are retained, and a notice that the code was
    17  * modified is included with the above copyright notice.
    18  *
    19  */ 
    20 // WARNING: This is an internal header file, included by other C++
    21 // standard library headers.  You should not attempt to use this header
    22 // file directly.
    23 
    24 
    25 #ifndef _STLP_INTERNAL_CODECVT_H
    26 #define _STLP_INTERNAL_CODECVT_H
    27 
    28 # ifndef _STLP_C_LOCALE_H
    29 #  include <stl/c_locale.h>
    30 # endif
    31 # ifndef _STLP_INTERNAL_LOCALE_H
    32 #  include <stl/_locale.h>
    33 # endif
    34 
    35 _STLP_BEGIN_NAMESPACE
    36 
    37 class _STLP_CLASS_DECLSPEC codecvt_base {
    38 public:
    39   enum result {ok, partial, error, noconv};
    40 };
    41 
    42 template <class _InternT, class _ExternT, class _StateT>
    43 class codecvt : public locale::facet, public codecvt_base {
    44   typedef _InternT intern_type;
    45   typedef _ExternT extern_type;
    46   typedef _StateT state_type;
    47 };
    48  
    49 template <class _InternT, class _ExternT, class _StateT>
    50 class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> {};
    51 
    52 _STLP_TEMPLATE_NULL
    53 #ifdef __SYMBIAN32__
    54 class codecvt<char, char, mbstate_t> : public locale::facet, public codecvt_base
    55 #else
    56 class _STLP_CLASS_DECLSPEC codecvt<char, char, mbstate_t> : public locale::facet, public codecvt_base
    57 #endif
    58 {
    59   friend class _Locale;
    60 public:
    61   typedef char       intern_type;
    62   typedef char       extern_type;
    63   typedef mbstate_t  state_type;
    64 
    65   explicit codecvt(size_t __refs = 0) : _BaseFacet(__refs) {}
    66 
    67   result out(state_type&  __state,
    68              const char*  __from,
    69              const char*  __from_end,
    70              const char*& __from_next,
    71              char*        __to,
    72              char*        __to_limit, 
    73              char*&       __to_next) const {
    74     return do_out(__state, 
    75                   __from, __from_end, __from_next,
    76                   __to,   __to_limit, __to_next);
    77   }
    78 
    79   result unshift(mbstate_t& __state,
    80                  char* __to, char* __to_limit, char*& __to_next) const
    81     { return do_unshift(__state, __to, __to_limit, __to_next); }
    82     
    83   result in(state_type&   __state,
    84             const char*  __from,
    85             const char*  __from_end,  
    86             const char*& __from_next,
    87             char*        __to, 
    88             char*        __to_limit, 
    89             char*&       __to_next) const {
    90     return do_in(__state,
    91                  __from, __from_end, __from_next,
    92                  __to,   __to_limit, __to_next);
    93   }
    94 
    95   int encoding() const _STLP_NOTHROW { return do_encoding(); }
    96 
    97   bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); }
    98 
    99   int length(const state_type& __state,
   100              const char* __from, const char* __end,
   101              size_t __max) const
   102     { return do_length(__state, __from, __end, __max); }
   103   
   104   int max_length() const _STLP_NOTHROW { return do_max_length(); }
   105 
   106 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
   107     _STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId();
   108 #else
   109   _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
   110 #endif
   111 
   112 protected:
   113 _STLP_DECLSPEC  ~codecvt();
   114 
   115   _STLP_DECLSPEC virtual result do_out(mbstate_t&   /* __state */,
   116                         const char*  __from,
   117                         const char*  /* __from_end */,
   118                         const char*& __from_next,
   119                         char*        __to,
   120                         char*        /* __to_limit */,
   121                         char*&       __to_next) const;
   122 
   123     _STLP_DECLSPEC virtual result do_in (mbstate_t&   /* __state */ , 
   124                         const char*  __from,
   125                         const char*  /* __from_end */,
   126                         const char*& __from_next,
   127                         char*        __to,
   128                         char*        /* __to_end */,
   129                         char*&       __to_next) const;
   130 
   131   _STLP_DECLSPEC   virtual result do_unshift(mbstate_t& /* __state */,
   132                             char*      __to,
   133                             char*      /* __to_limit */,
   134                             char*&     __to_next) const;
   135 
   136   _STLP_DECLSPEC   virtual int do_encoding() const _STLP_NOTHROW;
   137   _STLP_DECLSPEC   virtual bool do_always_noconv() const _STLP_NOTHROW;
   138   _STLP_DECLSPEC   virtual int do_length(const mbstate_t&         __state,
   139                         const  char* __from, 
   140                         const  char* __end,
   141                         size_t __max) const;
   142   _STLP_DECLSPEC   virtual int do_max_length() const _STLP_NOTHROW;
   143 private:
   144   codecvt(const codecvt<char, char, mbstate_t>&);
   145   codecvt<char, char, mbstate_t>& operator =(const codecvt<char, char, mbstate_t>&); 
   146 };
   147 
   148 # ifndef _STLP_NO_WCHAR_T
   149  
   150 _STLP_TEMPLATE_NULL
   151 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
   152 class codecvt<wchar_t, char, mbstate_t>  : public locale::facet, public codecvt_base
   153 #else
   154 class _STLP_CLASS_DECLSPEC codecvt<wchar_t, char, mbstate_t>  : public locale::facet, public codecvt_base
   155 #endif
   156 {
   157   friend class _Locale;
   158 public:
   159   typedef wchar_t    intern_type;
   160   typedef char       extern_type;
   161   typedef mbstate_t  state_type;
   162 
   163   explicit codecvt(size_t __refs = 0) : _BaseFacet(__refs) {}
   164 
   165   result out(mbstate_t&       __state,
   166              const wchar_t*  __from,
   167              const wchar_t*  __from_end,
   168              const wchar_t*& __from_next,
   169              char*           __to,
   170              char*           __to_limit,
   171              char*&          __to_next) const {
   172     return do_out(__state,
   173                   __from, __from_end, __from_next, 
   174                   __to,   __to_limit, __to_next);
   175   }
   176 
   177   result unshift(mbstate_t& __state,
   178                  char*  __to, char*  __to_limit, char*& __to_next) const {
   179     return do_unshift(__state, __to, __to_limit, __to_next);
   180   }
   181     
   182   result in(mbstate_t&    __state,
   183             const char*  __from,
   184             const char*  __from_end,  
   185             const char*& __from_next,
   186             wchar_t*     __to, 
   187             wchar_t*     __to_limit, 
   188             wchar_t*&    __to_next) const {
   189     return do_in(__state, 
   190                  __from, __from_end, __from_next,
   191                  __to,  __to_limit, __to_next);
   192   }
   193 
   194   int encoding() const _STLP_NOTHROW { return do_encoding(); }
   195 
   196   bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); }
   197 
   198   int length(const mbstate_t&        __state,
   199              const char* __from,
   200              const char* __end,
   201              size_t             __max) const
   202     { return do_length(__state, __from, __end, __max); }
   203   
   204   int max_length() const _STLP_NOTHROW { return do_max_length(); }
   205 
   206 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
   207 	_STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId();
   208 #else
   209   	_STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
   210 #endif
   211 
   212 protected:
   213     _STLP_DECLSPEC  ~codecvt();
   214 
   215   _STLP_DECLSPEC   virtual result do_out(mbstate_t&         __state,
   216                         const wchar_t*  __from,
   217                         const wchar_t*  __from_end,
   218                         const wchar_t*& __from_next,
   219                         char*        __to,
   220                         char*        __to_limit,
   221                         char*&       __to_next) const;
   222 
   223   _STLP_DECLSPEC   virtual result do_in (mbstate_t&         __state,
   224                         const char*  __from,
   225                         const char*  __from_end,
   226                         const char*& __from_next,
   227                         wchar_t*        __to,
   228                         wchar_t*        __to_limit,
   229                         wchar_t*&       __to_next) const;
   230 
   231   _STLP_DECLSPEC   virtual result do_unshift(mbstate_t&   __state,
   232                             char*  __to, 
   233                             char*  __to_limit,
   234                             char*& __to_next) const;
   235 
   236   _STLP_DECLSPEC   virtual int do_encoding() const _STLP_NOTHROW;
   237 
   238   _STLP_DECLSPEC   virtual bool do_always_noconv() const _STLP_NOTHROW;
   239   
   240   _STLP_DECLSPEC   virtual int do_length(const mbstate_t& __state,
   241                         const  char* __from, 
   242                         const  char* __end,
   243                         size_t __max) const;
   244 
   245   _STLP_DECLSPEC   virtual int do_max_length() const _STLP_NOTHROW;
   246 
   247 private:
   248   codecvt(const codecvt<wchar_t, char, mbstate_t>&);
   249   codecvt<wchar_t, char, mbstate_t>& operator = (const codecvt<wchar_t, char, mbstate_t>&);  
   250 };
   251 
   252 # endif
   253 
   254 _STLP_TEMPLATE_NULL
   255 class _STLP_CLASS_DECLSPEC codecvt_byname<char, char, mbstate_t>
   256   : public codecvt<char, char, mbstate_t> {
   257 public:
   258   explicit _STLP_DECLSPEC codecvt_byname(const char* __name, size_t __refs = 0);
   259   ~codecvt_byname();
   260 private:
   261   codecvt_byname(const codecvt_byname<char, char, mbstate_t>&);
   262   codecvt_byname<char, char, mbstate_t>& operator =(const codecvt_byname<char, char, mbstate_t>&);  
   263 };
   264 
   265 # ifndef _STLP_NO_WCHAR_T
   266 _STLP_TEMPLATE_NULL
   267 class codecvt_byname<wchar_t, char, mbstate_t>
   268   : public codecvt<wchar_t, char, mbstate_t> 
   269 {
   270 public:
   271   explicit _STLP_DECLSPEC codecvt_byname(const char * __name, size_t __refs = 0);    
   272 
   273 protected:
   274     _STLP_DECLSPEC ~codecvt_byname();
   275 
   276   _STLP_DECLSPEC   virtual result do_out(mbstate_t&         __state,
   277                         const wchar_t*  __from,
   278                         const wchar_t*  __from_end,
   279                         const wchar_t*& __from_next,
   280                         char*        __to,
   281                         char*        __to_limit,
   282                         char*&       __to_next) const;
   283 
   284   _STLP_DECLSPEC   virtual result do_in (mbstate_t&         __state,
   285                         const char*  __from,
   286                         const char*  __from_end,
   287                         const char*& __from_next,
   288                         wchar_t*        __to,
   289                         wchar_t*        __to_limit,
   290                         wchar_t*&       __to_next) const;
   291 
   292   _STLP_DECLSPEC   virtual result do_unshift(mbstate_t&   __state,
   293                             char*  __to, 
   294                             char*  __to_limit,
   295                             char*& __to_next) const;
   296 
   297   _STLP_DECLSPEC   virtual int do_encoding() const _STLP_NOTHROW;
   298 
   299   _STLP_DECLSPEC   virtual bool do_always_noconv() const _STLP_NOTHROW;
   300   
   301   _STLP_DECLSPEC   virtual int do_length(const mbstate_t&         __state,
   302                         const  char* __from, 
   303                         const  char* __end,
   304                         size_t __max) const;
   305 
   306   _STLP_DECLSPEC   virtual int do_max_length() const _STLP_NOTHROW;
   307 
   308 private:
   309   _Locale_ctype* _M_ctype;
   310   codecvt_byname(const codecvt_byname<wchar_t, char, mbstate_t>&);
   311   codecvt_byname<wchar_t, char, mbstate_t>& operator =(const codecvt_byname<wchar_t, char, mbstate_t>&);  
   312 };
   313 
   314 # endif
   315 
   316 _STLP_END_NAMESPACE
   317 
   318 #endif /* _STLP_INTERNAL_CODECVT_H */
   319 
   320 // Local Variables:
   321 // mode:C++
   322 // End:
   323