epoc32/include/tools/stlport/stl/_codecvt.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tools/stlport/stl/_codecvt.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,425 @@
     1.4 +/*
     1.5 + * Copyright (c) 1999
     1.6 + * Silicon Graphics Computer Systems, Inc.
     1.7 + *
     1.8 + * Copyright (c) 1999
     1.9 + * Boris Fomitchev
    1.10 + *
    1.11 + * This material is provided "as is", with absolutely no warranty expressed
    1.12 + * or implied. Any use is at your own risk.
    1.13 + *
    1.14 + * Permission to use or copy this software for any purpose is hereby granted
    1.15 + * without fee, provided the above notices are retained on all copies.
    1.16 + * Permission to modify the code and to distribute modified code is granted,
    1.17 + * provided the above notices are retained, and a notice that the code was
    1.18 + * modified is included with the above copyright notice.
    1.19 + *
    1.20 + */
    1.21 +// WARNING: This is an internal header file, included by other C++
    1.22 +// standard library headers.  You should not attempt to use this header
    1.23 +// file directly.
    1.24 +
    1.25 +
    1.26 +#ifndef _STLP_INTERNAL_CODECVT_H
    1.27 +#define _STLP_INTERNAL_CODECVT_H
    1.28 +
    1.29 +#ifndef _STLP_C_LOCALE_H
    1.30 +#  include <stl/c_locale.h>
    1.31 +#endif
    1.32 +
    1.33 +#ifndef _STLP_INTERNAL_LOCALE_H
    1.34 +#  include <stl/_locale.h>
    1.35 +#endif
    1.36 +
    1.37 +#ifndef _STLP_INTERNAL_ALGOBASE_H
    1.38 +#  include <stl/_algobase.h>
    1.39 +#endif
    1.40 +
    1.41 +_STLP_BEGIN_NAMESPACE
    1.42 +
    1.43 +class _STLP_CLASS_DECLSPEC codecvt_base {
    1.44 +public:
    1.45 +  enum result {ok, partial, error, noconv};
    1.46 +};
    1.47 +
    1.48 +template <class _InternT, class _ExternT, class _StateT>
    1.49 +class codecvt : public locale::facet, public codecvt_base {
    1.50 +public:
    1.51 +  typedef _InternT intern_type;
    1.52 +  typedef _ExternT extern_type;
    1.53 +  typedef _StateT state_type;
    1.54 +
    1.55 +#if defined (_STLP_MSVC) && (_STLP_MSVC < 1300)
    1.56 +  /* For the moment VC6 do not support this facet default implementation
    1.57 +   * because of the static locale::id instance. When VC6 see this definition
    1.58 +   * it goes crasy with locale::id static instances and all the has_facet tests
    1.59 +   * unit tests are failing.
    1.60 +   */
    1.61 +};
    1.62 +#else
    1.63 +  explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {}
    1.64 +
    1.65 +  result out(state_type&          __state,
    1.66 +             const intern_type*   __from,
    1.67 +             const intern_type*   __from_end,
    1.68 +             const intern_type*&  __from_next,
    1.69 +             extern_type*         __to,
    1.70 +             extern_type*         __to_limit,
    1.71 +             extern_type*&        __to_next) const {
    1.72 +    return do_out(__state,
    1.73 +                  __from, __from_end, __from_next,
    1.74 +                  __to,   __to_limit, __to_next);
    1.75 +  }
    1.76 +
    1.77 +  result unshift(state_type&    __state,
    1.78 +                 extern_type*   __to,
    1.79 +                 extern_type*   __to_limit,
    1.80 +                 extern_type*&  __to_next) const {
    1.81 +    return do_unshift(__state, __to, __to_limit, __to_next);
    1.82 +  }
    1.83 +
    1.84 +  result in(state_type&         __state,
    1.85 +            const extern_type*  __from,
    1.86 +            const extern_type*  __from_end,
    1.87 +            const extern_type*& __from_next,
    1.88 +            intern_type*        __to,
    1.89 +            intern_type*        __to_limit,
    1.90 +            intern_type*&       __to_next) const {
    1.91 +    return do_in(__state,
    1.92 +                 __from, __from_end, __from_next,
    1.93 +                 __to,  __to_limit, __to_next);
    1.94 +  }
    1.95 +
    1.96 +  int encoding() const _STLP_NOTHROW { return do_encoding(); }
    1.97 +
    1.98 +  bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); }
    1.99 +
   1.100 +  int length(const state_type&  __state,
   1.101 +             const extern_type* __from,
   1.102 +             const extern_type* __end,
   1.103 +             size_t             __max) const {
   1.104 +    return do_length(__state, __from, __end, __max);
   1.105 +  }
   1.106 +
   1.107 +  int max_length() const _STLP_NOTHROW { return do_max_length(); }
   1.108 +
   1.109 +  static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
   1.110 +
   1.111 +protected:
   1.112 +  ~codecvt() {}
   1.113 +
   1.114 +  virtual result do_out(state_type&,
   1.115 +                        const intern_type*  __from,
   1.116 +                        const intern_type*,
   1.117 +                        const intern_type*& __from_next,
   1.118 +                        extern_type*        __to,
   1.119 +                        extern_type*,
   1.120 +                        extern_type*&       __to_next) const
   1.121 +  { __from_next = __from; __to_next   = __to; return noconv; }
   1.122 +
   1.123 +  virtual result do_in (state_type&,
   1.124 +                        const extern_type*  __from,
   1.125 +                        const extern_type*,
   1.126 +                        const extern_type*& __from_next,
   1.127 +                        intern_type*        __to,
   1.128 +                        intern_type*,
   1.129 +                        intern_type*&       __to_next) const
   1.130 +  { __from_next = __from; __to_next = __to; return noconv; }
   1.131 +
   1.132 +  virtual result do_unshift(state_type&,
   1.133 +                            extern_type* __to,
   1.134 +                            extern_type*,
   1.135 +                            extern_type*& __to_next) const
   1.136 +  { __to_next = __to; return noconv; }
   1.137 +
   1.138 +  virtual int do_encoding() const _STLP_NOTHROW
   1.139 +  { return 1; }
   1.140 +
   1.141 +  virtual bool do_always_noconv() const _STLP_NOTHROW
   1.142 +  { return true; }
   1.143 +
   1.144 +  virtual int do_length(const state_type&,
   1.145 +                        const extern_type* __from,
   1.146 +                        const extern_type* __end,
   1.147 +                        size_t __max) const
   1.148 +  { return (int)(min) ( __STATIC_CAST(size_t, (__end - __from)), __max); }
   1.149 +
   1.150 +  virtual int do_max_length() const _STLP_NOTHROW
   1.151 +  { return 1; }
   1.152 +
   1.153 +private:
   1.154 +  codecvt(const codecvt<intern_type, extern_type, state_type>&);
   1.155 +  codecvt<intern_type, extern_type, state_type>& operator = (const codecvt<intern_type, extern_type, state_type>&);
   1.156 +};
   1.157 +
   1.158 +#  if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
   1.159 +#    if (_STLP_STATIC_TEMPLATE_DATA > 0)
   1.160 +#      if !defined (__BORLANDC__)
   1.161 +template <class _InternT, class _ExternT, class _StateT>
   1.162 +locale::id codecvt<_InternT, _ExternT, _StateT>::id;
   1.163 +#      endif
   1.164 +#    endif
   1.165 +#  endif
   1.166 +#endif
   1.167 +
   1.168 +template <class _InternT, class _ExternT, class _StateT>
   1.169 +class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> {};
   1.170 +
   1.171 +_STLP_TEMPLATE_NULL
   1.172 +class _STLP_CLASS_DECLSPEC codecvt<char, char, mbstate_t>
   1.173 +  : public locale::facet, public codecvt_base
   1.174 +{
   1.175 +  friend class _Locale_impl;
   1.176 +
   1.177 +public:
   1.178 +  typedef char       intern_type;
   1.179 +  typedef char       extern_type;
   1.180 +  typedef mbstate_t  state_type;
   1.181 +
   1.182 +  explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {}
   1.183 +
   1.184 +  result out(mbstate_t&   __state,
   1.185 +             const char*  __from,
   1.186 +             const char*  __from_end,
   1.187 +             const char*& __from_next,
   1.188 +             char*        __to,
   1.189 +             char*        __to_limit,
   1.190 +             char*&       __to_next) const {
   1.191 +    return do_out(__state,
   1.192 +                  __from, __from_end, __from_next,
   1.193 +                  __to,   __to_limit, __to_next);
   1.194 +  }
   1.195 +
   1.196 +  result unshift(mbstate_t& __state,
   1.197 +                 char* __to, char* __to_limit, char*& __to_next) const
   1.198 +    { return do_unshift(__state, __to, __to_limit, __to_next); }
   1.199 +
   1.200 +  result in(state_type&   __state,
   1.201 +            const char*  __from,
   1.202 +            const char*  __from_end,
   1.203 +            const char*& __from_next,
   1.204 +            char*        __to,
   1.205 +            char*        __to_limit,
   1.206 +            char*&       __to_next) const {
   1.207 +    return do_in(__state,
   1.208 +                 __from, __from_end, __from_next,
   1.209 +                 __to,   __to_limit, __to_next);
   1.210 +  }
   1.211 +
   1.212 +  int encoding() const _STLP_NOTHROW { return do_encoding(); }
   1.213 +
   1.214 +  bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); }
   1.215 +
   1.216 +  int length(const state_type& __state,
   1.217 +             const char* __from, const char* __end,
   1.218 +             size_t __max) const
   1.219 +    { return do_length(__state, __from, __end, __max); }
   1.220 +
   1.221 +  int max_length() const _STLP_NOTHROW { return do_max_length(); }
   1.222 +
   1.223 +  static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
   1.224 +
   1.225 +protected:
   1.226 +  ~codecvt();
   1.227 +
   1.228 +  virtual result do_out(mbstate_t&   /* __state */,
   1.229 +                        const char*  __from,
   1.230 +                        const char*  /* __from_end */,
   1.231 +                        const char*& __from_next,
   1.232 +                        char*        __to,
   1.233 +                        char*        /* __to_limit */,
   1.234 +                        char*&       __to_next) const;
   1.235 +
   1.236 +  virtual result do_in (mbstate_t&   /* __state */ ,
   1.237 +                        const char*  __from,
   1.238 +                        const char*  /* __from_end */,
   1.239 +                        const char*& __from_next,
   1.240 +                        char*        __to,
   1.241 +                        char*        /* __to_end */,
   1.242 +                        char*&       __to_next) const;
   1.243 +
   1.244 +  virtual result do_unshift(mbstate_t& /* __state */,
   1.245 +                            char*      __to,
   1.246 +                            char*      /* __to_limit */,
   1.247 +                            char*&     __to_next) const;
   1.248 +
   1.249 +  virtual int do_encoding() const _STLP_NOTHROW;
   1.250 +  virtual bool do_always_noconv() const _STLP_NOTHROW;
   1.251 +  virtual int do_length(const mbstate_t&         __state,
   1.252 +                        const  char* __from,
   1.253 +                        const  char* __end,
   1.254 +                        size_t __max) const;
   1.255 +  virtual int do_max_length() const _STLP_NOTHROW;
   1.256 +private:
   1.257 +  codecvt(const codecvt<char, char, mbstate_t>&);
   1.258 +  codecvt<char, char, mbstate_t>& operator =(const codecvt<char, char, mbstate_t>&);
   1.259 +};
   1.260 +
   1.261 +# ifndef _STLP_NO_WCHAR_T
   1.262 +
   1.263 +_STLP_TEMPLATE_NULL
   1.264 +class _STLP_CLASS_DECLSPEC codecvt<wchar_t, char, mbstate_t>
   1.265 +  : public locale::facet, public codecvt_base
   1.266 +{
   1.267 +  friend class _Locale_impl;
   1.268 +public:
   1.269 +  typedef wchar_t    intern_type;
   1.270 +  typedef char       extern_type;
   1.271 +  typedef mbstate_t  state_type;
   1.272 +
   1.273 +  explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {}
   1.274 +
   1.275 +  result out(mbstate_t&      __state,
   1.276 +             const wchar_t*  __from,
   1.277 +             const wchar_t*  __from_end,
   1.278 +             const wchar_t*& __from_next,
   1.279 +             char*           __to,
   1.280 +             char*           __to_limit,
   1.281 +             char*&          __to_next) const {
   1.282 +    return do_out(__state,
   1.283 +                  __from, __from_end, __from_next,
   1.284 +                  __to,   __to_limit, __to_next);
   1.285 +  }
   1.286 +
   1.287 +  result unshift(mbstate_t& __state,
   1.288 +                 char*  __to, char*  __to_limit, char*& __to_next) const {
   1.289 +    return do_unshift(__state, __to, __to_limit, __to_next);
   1.290 +  }
   1.291 +
   1.292 +  result in(mbstate_t&   __state,
   1.293 +            const char*  __from,
   1.294 +            const char*  __from_end,
   1.295 +            const char*& __from_next,
   1.296 +            wchar_t*     __to,
   1.297 +            wchar_t*     __to_limit,
   1.298 +            wchar_t*&    __to_next) const {
   1.299 +    return do_in(__state,
   1.300 +                 __from, __from_end, __from_next,
   1.301 +                 __to,   __to_limit, __to_next);
   1.302 +  }
   1.303 +
   1.304 +  int encoding() const _STLP_NOTHROW { return do_encoding(); }
   1.305 +
   1.306 +  bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); }
   1.307 +
   1.308 +  int length(const mbstate_t& __state,
   1.309 +             const char* __from, const char* __end,
   1.310 +             size_t __max) const
   1.311 +    { return do_length(__state, __from, __end, __max); }
   1.312 +
   1.313 +  int max_length() const _STLP_NOTHROW { return do_max_length(); }
   1.314 +
   1.315 +  static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
   1.316 +
   1.317 +protected:
   1.318 +  ~codecvt();
   1.319 +
   1.320 +  virtual result do_out(mbstate_t&         __state,
   1.321 +                        const wchar_t*  __from,
   1.322 +                        const wchar_t*  __from_end,
   1.323 +                        const wchar_t*& __from_next,
   1.324 +                        char*        __to,
   1.325 +                        char*        __to_limit,
   1.326 +                        char*&       __to_next) const;
   1.327 +
   1.328 +  virtual result do_in (mbstate_t&         __state,
   1.329 +                        const char*  __from,
   1.330 +                        const char*  __from_end,
   1.331 +                        const char*& __from_next,
   1.332 +                        wchar_t*        __to,
   1.333 +                        wchar_t*        __to_limit,
   1.334 +                        wchar_t*&       __to_next) const;
   1.335 +
   1.336 +  virtual result do_unshift(mbstate_t&   __state,
   1.337 +                            char*  __to,
   1.338 +                            char*  __to_limit,
   1.339 +                            char*& __to_next) const;
   1.340 +
   1.341 +  virtual int do_encoding() const _STLP_NOTHROW;
   1.342 +
   1.343 +  virtual bool do_always_noconv() const _STLP_NOTHROW;
   1.344 +
   1.345 +  virtual int do_length(const mbstate_t& __state,
   1.346 +                        const  char* __from,
   1.347 +                        const  char* __end,
   1.348 +                        size_t __max) const;
   1.349 +
   1.350 +  virtual int do_max_length() const _STLP_NOTHROW;
   1.351 +
   1.352 +private:
   1.353 +  codecvt(const codecvt<wchar_t, char, mbstate_t>&);
   1.354 +  codecvt<wchar_t, char, mbstate_t>& operator = (const codecvt<wchar_t, char, mbstate_t>&);
   1.355 +};
   1.356 +
   1.357 +# endif
   1.358 +
   1.359 +_STLP_TEMPLATE_NULL
   1.360 +class _STLP_CLASS_DECLSPEC codecvt_byname<char, char, mbstate_t>
   1.361 +  : public codecvt<char, char, mbstate_t> {
   1.362 +public:
   1.363 +  explicit codecvt_byname(const char* __name, size_t __refs = 0);
   1.364 +  ~codecvt_byname();
   1.365 +private:
   1.366 +  codecvt_byname(const codecvt_byname<char, char, mbstate_t>&);
   1.367 +  codecvt_byname<char, char, mbstate_t>& operator =(const codecvt_byname<char, char, mbstate_t>&);
   1.368 +};
   1.369 +
   1.370 +# ifndef _STLP_NO_WCHAR_T
   1.371 +_STLP_TEMPLATE_NULL
   1.372 +class _STLP_CLASS_DECLSPEC codecvt_byname<wchar_t, char, mbstate_t>
   1.373 +  : public codecvt<wchar_t, char, mbstate_t>
   1.374 +{
   1.375 +public:
   1.376 +  explicit codecvt_byname(const char * __name, size_t __refs = 0, _Locale_name_hint* __hint = 0);
   1.377 +
   1.378 +protected:
   1.379 +  ~codecvt_byname();
   1.380 +
   1.381 +  virtual result do_out(mbstate_t&         __state,
   1.382 +                        const wchar_t*  __from,
   1.383 +                        const wchar_t*  __from_end,
   1.384 +                        const wchar_t*& __from_next,
   1.385 +                        char*        __to,
   1.386 +                        char*        __to_limit,
   1.387 +                        char*&       __to_next) const;
   1.388 +
   1.389 +  virtual result do_in (mbstate_t&         __state,
   1.390 +                        const char*  __from,
   1.391 +                        const char*  __from_end,
   1.392 +                        const char*& __from_next,
   1.393 +                        wchar_t*        __to,
   1.394 +                        wchar_t*        __to_limit,
   1.395 +                        wchar_t*&       __to_next) const;
   1.396 +
   1.397 +  virtual result do_unshift(mbstate_t&   __state,
   1.398 +                            char*  __to,
   1.399 +                            char*  __to_limit,
   1.400 +                            char*& __to_next) const;
   1.401 +
   1.402 +  virtual int do_encoding() const _STLP_NOTHROW;
   1.403 +
   1.404 +  virtual bool do_always_noconv() const _STLP_NOTHROW;
   1.405 +
   1.406 +  virtual int do_length(const mbstate_t&         __state,
   1.407 +                        const  char* __from,
   1.408 +                        const  char* __end,
   1.409 +                        size_t __max) const;
   1.410 +
   1.411 +  virtual int do_max_length() const _STLP_NOTHROW;
   1.412 +
   1.413 +private:
   1.414 +  _Locale_ctype* _M_ctype;
   1.415 +  codecvt_byname(const codecvt_byname<wchar_t, char, mbstate_t>&);
   1.416 +  codecvt_byname<wchar_t, char, mbstate_t>& operator =(const codecvt_byname<wchar_t, char, mbstate_t>&);
   1.417 +};
   1.418 +
   1.419 +# endif
   1.420 +
   1.421 +_STLP_END_NAMESPACE
   1.422 +
   1.423 +#endif /* _STLP_INTERNAL_CODECVT_H */
   1.424 +
   1.425 +// Local Variables:
   1.426 +// mode:C++
   1.427 +// End:
   1.428 +