1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/stdcpp/src/codecvt.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,167 @@
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 +# ifndef _STLP_NO_MBSTATE_T
1.24 +
1.25 +#include <stl/_codecvt.h>
1.26 +#include <stl/_algobase.h>
1.27 +
1.28 +_STLP_BEGIN_NAMESPACE
1.29 +
1.30 +//----------------------------------------------------------------------
1.31 +// codecvt<char, char, mbstate_t>
1.32 +
1.33 +_STLP_EXP_DECLSPEC codecvt<char, char, mbstate_t>::~codecvt() {}
1.34 +
1.35 +_STLP_EXP_DECLSPEC int codecvt<char, char, mbstate_t>::do_length(const mbstate_t&,
1.36 + const char* from,
1.37 + const char* end,
1.38 + size_t mx) const
1.39 +{
1.40 + return (int)(min) ( __STATIC_CAST(size_t, (end - from)), mx);
1.41 +}
1.42 +
1.43 +_STLP_EXP_DECLSPEC int codecvt<char, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
1.44 +{
1.45 + return 1;
1.46 +}
1.47 +
1.48 +bool _STLP_EXP_DECLSPEC
1.49 +codecvt<char, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
1.50 +{
1.51 + return true;
1.52 +}
1.53 +
1.54 +_STLP_EXP_DECLSPEC int
1.55 +codecvt<char, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
1.56 +{
1.57 + return 1;
1.58 +}
1.59 +
1.60 +
1.61 +_STLP_EXP_DECLSPEC codecvt_base::result
1.62 +codecvt<char, char, mbstate_t>::do_unshift(mbstate_t& /* __state */,
1.63 + char* __to,
1.64 + char* /* __to_limit */,
1.65 + char*& __to_next) const
1.66 +{ __to_next = __to; return noconv; }
1.67 +
1.68 + _STLP_EXP_DECLSPEC codecvt_base::result
1.69 +codecvt<char, char, mbstate_t>::do_in (mbstate_t& /* __state */ ,
1.70 + const char* __from,
1.71 + const char* /* __from_end */,
1.72 + const char*& __from_next,
1.73 + char* __to,
1.74 + char* /* __to_end */,
1.75 + char*& __to_next) const
1.76 +{ __from_next = __from; __to_next = __to; return noconv; }
1.77 +
1.78 +_STLP_EXP_DECLSPEC codecvt_base::result
1.79 +codecvt<char, char, mbstate_t>::do_out(mbstate_t& /* __state */,
1.80 + const char* __from,
1.81 + const char* /* __from_end */,
1.82 + const char*& __from_next,
1.83 + char* __to,
1.84 + char* /* __to_limit */,
1.85 + char*& __to_next) const
1.86 +{ __from_next = __from; __to_next = __to; return noconv; }
1.87 +
1.88 +
1.89 +# ifndef _STLP_NO_WCHAR_T
1.90 +//----------------------------------------------------------------------
1.91 +// codecvt<wchar_t, char, mbstate_t>
1.92 +
1.93 +_STLP_EXP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::~codecvt() {}
1.94 +
1.95 +
1.96 +_STLP_EXP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result
1.97 +codecvt<wchar_t, char, mbstate_t>::do_out(state_type& /* state */,
1.98 + const intern_type* from,
1.99 + const intern_type* from_end,
1.100 + const intern_type*& from_next,
1.101 + extern_type* to,
1.102 + extern_type* to_limit,
1.103 + extern_type*& to_next) const
1.104 +{
1.105 + ptrdiff_t len = (min) (from_end - from, to_limit - to);
1.106 + copy(from, from + len, to);
1.107 + from_next = from + len;
1.108 + to_next = to + len;
1.109 + return ok;
1.110 +}
1.111 +
1.112 +_STLP_EXP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result
1.113 +codecvt<wchar_t, char, mbstate_t>::do_in (state_type& /* state */,
1.114 + const extern_type* from,
1.115 + const extern_type* from_end,
1.116 + const extern_type*& from_next,
1.117 + intern_type* to,
1.118 + intern_type* to_limit,
1.119 + intern_type*& to_next) const
1.120 +{
1.121 + ptrdiff_t len = (min) (from_end - from, to_limit - to);
1.122 + copy(from, from + len, to);
1.123 + from_next = from + len;
1.124 + to_next = to + len;
1.125 + return ok;
1.126 +}
1.127 +
1.128 +_STLP_EXP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result
1.129 +codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& /* state */,
1.130 + extern_type* to,
1.131 + extern_type* ,
1.132 + extern_type*& to_next) const
1.133 +{
1.134 + to_next = to;
1.135 + return noconv;
1.136 +}
1.137 +
1.138 +_STLP_EXP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_encoding() const _STLP_NOTHROW {
1.139 + //return 1;
1.140 + return 0;//don't know how many char required to make wchar_t, depends on locale
1.141 +}
1.142 +
1.143 +
1.144 +_STLP_EXP_DECLSPEC bool codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
1.145 +{
1.146 + // return true; //gnu bug fix
1.147 + return false;
1.148 +}
1.149 +
1.150 +_STLP_EXP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_length(const state_type&,
1.151 + const extern_type* from,
1.152 + const extern_type* end,
1.153 + size_t mx) const
1.154 +{
1.155 + return (int)(min) ((size_t) (end - from), mx);
1.156 +}
1.157 +
1.158 +_STLP_EXP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_max_length() const _STLP_NOTHROW {
1.159 + return 1;
1.160 +}
1.161 +# endif /* wchar_t */
1.162 +
1.163 +_STLP_END_NAMESPACE
1.164 +
1.165 +# endif /* _STLP_NO_MBSTATE_T */
1.166 +
1.167 +// Local Variables:
1.168 +// mode:C++
1.169 +// End:
1.170 +