1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/src/codecvt.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,158 @@
1.4 +/*
1.5 + * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.6 + *
1.7 + * Copyright (c) 1999
1.8 + * Silicon Graphics Computer Systems, Inc.
1.9 + *
1.10 + * Copyright (c) 1999
1.11 + * Boris Fomitchev
1.12 + *
1.13 + * This material is provided "as is", with absolutely no warranty expressed
1.14 + * or implied. Any use is at your own risk.
1.15 + *
1.16 + * Permission to use or copy this software for any purpose is hereby granted
1.17 + * without fee, provided the above notices are retained on all copies.
1.18 + * Permission to modify the code and to distribute modified code is granted,
1.19 + * provided the above notices are retained, and a notice that the code was
1.20 + * modified is included with the above copyright notice.
1.21 + *
1.22 + */
1.23 +#include "stlport_prefix.h"
1.24 +
1.25 +#ifndef _STLP_NO_MBSTATE_T
1.26 +
1.27 +#include <locale>
1.28 +#include <algorithm>
1.29 +
1.30 +_STLP_BEGIN_NAMESPACE
1.31 +
1.32 +//----------------------------------------------------------------------
1.33 +// codecvt<char, char, mbstate_t>
1.34 +
1.35 +_STLP_DECLSPEC codecvt<char, char, mbstate_t>::~codecvt() {}
1.36 +
1.37 +_STLP_DECLSPEC int codecvt<char, char, mbstate_t>::do_length(const mbstate_t&,
1.38 + const char* from,
1.39 + const char* end,
1.40 + size_t mx) const
1.41 +{ return (int)(min) ( __STATIC_CAST(size_t, (end - from)), mx); }
1.42 +
1.43 +_STLP_DECLSPEC int codecvt<char, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
1.44 +{ return 1; }
1.45 +
1.46 +_STLP_DECLSPEC bool
1.47 +codecvt<char, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
1.48 +{ return true; }
1.49 +
1.50 +_STLP_DECLSPEC int
1.51 +codecvt<char, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
1.52 +{ return 1; }
1.53 +
1.54 +_STLP_DECLSPEC codecvt_base::result
1.55 +codecvt<char, char, mbstate_t>::do_unshift(mbstate_t& /* __state */,
1.56 + char* __to,
1.57 + char* /* __to_limit */,
1.58 + char*& __to_next) const
1.59 +{ __to_next = __to; return noconv; }
1.60 +
1.61 +_STLP_DECLSPEC codecvt_base::result
1.62 +codecvt<char, char, mbstate_t>::do_in (mbstate_t& /* __state */ ,
1.63 + const char* __from,
1.64 + const char* /* __from_end */,
1.65 + const char*& __from_next,
1.66 + char* __to,
1.67 + char* /* __to_end */,
1.68 + char*& __to_next) const
1.69 +{ __from_next = __from; __to_next = __to; return noconv; }
1.70 +
1.71 +_STLP_DECLSPEC codecvt_base::result
1.72 +codecvt<char, char, mbstate_t>::do_out(mbstate_t& /* __state */,
1.73 + const char* __from,
1.74 + const char* /* __from_end */,
1.75 + const char*& __from_next,
1.76 + char* __to,
1.77 + char* /* __to_limit */,
1.78 + char*& __to_next) const
1.79 +{ __from_next = __from; __to_next = __to; return noconv; }
1.80 +
1.81 +
1.82 +#if !defined (_STLP_NO_WCHAR_T)
1.83 +//----------------------------------------------------------------------
1.84 +// codecvt<wchar_t, char, mbstate_t>
1.85 +
1.86 +_STLP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::~codecvt() {}
1.87 +
1.88 +
1.89 +_STLP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result
1.90 +codecvt<wchar_t, char, mbstate_t>::do_out(state_type& /* state */,
1.91 + const intern_type* from,
1.92 + const intern_type* from_end,
1.93 + const intern_type*& from_next,
1.94 + extern_type* to,
1.95 + extern_type* to_limit,
1.96 + extern_type*& to_next) const {
1.97 + ptrdiff_t len = (min) (from_end - from, to_limit - to);
1.98 + copy(from, from + len, to);
1.99 + from_next = from + len;
1.100 + to_next = to + len;
1.101 + return ok;
1.102 +}
1.103 +
1.104 +_STLP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result
1.105 +codecvt<wchar_t, char, mbstate_t>::do_in (state_type& /* state */,
1.106 + const extern_type* from,
1.107 + const extern_type* from_end,
1.108 + const extern_type*& from_next,
1.109 + intern_type* to,
1.110 + intern_type* to_limit,
1.111 + intern_type*& to_next) const {
1.112 + ptrdiff_t len = (min) (from_end - from, to_limit - to);
1.113 + copy(__REINTERPRET_CAST(const unsigned char*, from),
1.114 + __REINTERPRET_CAST(const unsigned char*, from) + len, to);
1.115 + from_next = from + len;
1.116 + to_next = to + len;
1.117 + return ok;
1.118 +}
1.119 +
1.120 +_STLP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result
1.121 +codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& /* state */,
1.122 + extern_type* to,
1.123 + extern_type* ,
1.124 + extern_type*& to_next) const {
1.125 + to_next = to;
1.126 + return noconv;
1.127 +}
1.128 +
1.129 +_STLP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
1.130 +#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
1.131 +{
1.132 + int __ret = 0;
1.133 + if (MB_CUR_MAX == 1)
1.134 + __ret = 1;
1.135 + return __ret;
1.136 + }
1.137 +#else
1.138 +{ return 1; }
1.139 +#endif
1.140 +
1.141 +_STLP_DECLSPEC bool codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
1.142 +{ return true; }
1.143 +
1.144 +_STLP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_length(const state_type&,
1.145 + const extern_type* from,
1.146 + const extern_type* end,
1.147 + size_t mx) const
1.148 +{ return (int)(min) ((size_t) (end - from), mx); }
1.149 +
1.150 +_STLP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
1.151 +{ return 1; }
1.152 +#endif /* wchar_t */
1.153 +
1.154 +_STLP_END_NAMESPACE
1.155 +
1.156 +#endif /* _STLP_NO_MBSTATE_T */
1.157 +
1.158 +// Local Variables:
1.159 +// mode:C++
1.160 +// End:
1.161 +