build/stlport/src/codecvt.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build/stlport/src/codecvt.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,143 @@
     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 +#include "stlport_prefix.h"
    1.22 +
    1.23 +#include <locale>
    1.24 +#include <algorithm>
    1.25 +
    1.26 +_STLP_BEGIN_NAMESPACE
    1.27 +
    1.28 +//----------------------------------------------------------------------
    1.29 +// codecvt<char, char, mbstate_t>
    1.30 +
    1.31 +codecvt<char, char, mbstate_t>::~codecvt() {}
    1.32 +
    1.33 +int codecvt<char, char, mbstate_t>::do_length(state_type&,
    1.34 +                                              const  char* from,
    1.35 +                                              const  char* end,
    1.36 +                                              size_t mx) const
    1.37 +{ return (int)(min) ( __STATIC_CAST(size_t, (end - from)), mx); }
    1.38 +
    1.39 +int codecvt<char, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
    1.40 +{ return 1; }
    1.41 +
    1.42 +bool
    1.43 +codecvt<char, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
    1.44 +{ return true; }
    1.45 +
    1.46 +int
    1.47 +codecvt<char, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
    1.48 +{ return 1; }
    1.49 +
    1.50 +codecvt_base::result
    1.51 +codecvt<char, char, mbstate_t>::do_unshift(state_type& /* __state */,
    1.52 +                                           char*       __to,
    1.53 +                                           char*       /* __to_limit */,
    1.54 +                                           char*&      __to_next) const
    1.55 +{ __to_next = __to; return noconv; }
    1.56 +
    1.57 +codecvt_base::result
    1.58 +codecvt<char, char, mbstate_t>::do_in (state_type&  /* __state */ ,
    1.59 +                                       const char*  __from,
    1.60 +                                       const char*  /* __from_end */,
    1.61 +                                       const char*& __from_next,
    1.62 +                                       char*        __to,
    1.63 +                                       char*        /* __to_end */,
    1.64 +                                       char*&       __to_next) const
    1.65 +{ __from_next = __from; __to_next   = __to; return noconv; }
    1.66 +
    1.67 +codecvt_base::result
    1.68 +codecvt<char, char, mbstate_t>::do_out(state_type&  /* __state */,
    1.69 +                                       const char*  __from,
    1.70 +                                       const char*  /* __from_end */,
    1.71 +                                       const char*& __from_next,
    1.72 +                                       char*        __to,
    1.73 +                                       char*        /* __to_limit */,
    1.74 +                                       char*&       __to_next) const
    1.75 +{ __from_next = __from; __to_next   = __to; return noconv; }
    1.76 +
    1.77 +
    1.78 +#if !defined (_STLP_NO_WCHAR_T)
    1.79 +//----------------------------------------------------------------------
    1.80 +// codecvt<wchar_t, char, mbstate_t>
    1.81 +
    1.82 +codecvt<wchar_t, char, mbstate_t>::~codecvt() {}
    1.83 +
    1.84 +
    1.85 +codecvt<wchar_t, char, mbstate_t>::result
    1.86 +codecvt<wchar_t, char, mbstate_t>::do_out(state_type&         /* state */,
    1.87 +                                          const intern_type*  from,
    1.88 +                                          const intern_type*  from_end,
    1.89 +                                          const intern_type*& from_next,
    1.90 +                                          extern_type*        to,
    1.91 +                                          extern_type*        to_limit,
    1.92 +                                          extern_type*&       to_next) const {
    1.93 +  ptrdiff_t len = (min) (from_end - from, to_limit - to);
    1.94 +  copy(from, from + len, to);
    1.95 +  from_next = from + len;
    1.96 +  to_next   = to   + len;
    1.97 +  return ok;
    1.98 +}
    1.99 +
   1.100 +codecvt<wchar_t, char, mbstate_t>::result
   1.101 +codecvt<wchar_t, char, mbstate_t>::do_in (state_type&       /* state */,
   1.102 +                                          const extern_type*  from,
   1.103 +                                          const extern_type*  from_end,
   1.104 +                                          const extern_type*& from_next,
   1.105 +                                          intern_type*        to,
   1.106 +                                          intern_type*        to_limit,
   1.107 +                                          intern_type*&       to_next) const {
   1.108 +  ptrdiff_t len = (min) (from_end - from, to_limit - to);
   1.109 +  copy(__REINTERPRET_CAST(const unsigned char*, from),
   1.110 +       __REINTERPRET_CAST(const unsigned char*, from) + len, to);
   1.111 +  from_next = from + len;
   1.112 +  to_next   = to   + len;
   1.113 +  return ok;
   1.114 +}
   1.115 +
   1.116 +codecvt<wchar_t, char, mbstate_t>::result
   1.117 +codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type&   /* state */,
   1.118 +                                              extern_type*  to,
   1.119 +                                              extern_type*  ,
   1.120 +                                              extern_type*& to_next) const {
   1.121 +  to_next = to;
   1.122 +  return noconv;
   1.123 +}
   1.124 +
   1.125 +int codecvt<wchar_t, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
   1.126 +{ return 1; }
   1.127 +
   1.128 +bool codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
   1.129 +{ return true; }
   1.130 +
   1.131 +int codecvt<wchar_t, char, mbstate_t>::do_length(state_type&,
   1.132 +                                                 const  extern_type* from,
   1.133 +                                                 const  extern_type* end,
   1.134 +                                                 size_t mx) const
   1.135 +{ return (int)(min) ((size_t) (end - from), mx); }
   1.136 +
   1.137 +int codecvt<wchar_t, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
   1.138 +{ return 1; }
   1.139 +#endif /* wchar_t */
   1.140 +
   1.141 +_STLP_END_NAMESPACE
   1.142 +
   1.143 +// Local Variables:
   1.144 +// mode:C++
   1.145 +// End:
   1.146 +

mercurial