00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <bits/std_locale.h>
00031
00032 namespace std {
00033
00034 #ifdef _GLIBCPP_USE_WCHAR_T
00035
00036 const int __enc_traits::_S_max_size;
00037 #endif
00038
00039
00040 codecvt<char, char, mbstate_t>:: codecvt(size_t __refs)
00041 : __codecvt_abstract_base<char, char, mbstate_t>(__refs)
00042 { }
00043
00044
00045 codecvt<char, char, mbstate_t>:: ~codecvt() { }
00046
00047 codecvt_base::result
00048
00049 codecvt<char, char, mbstate_t>:: do_out(state_type& , const intern_type* __from,
00050 const intern_type* __from_end, const intern_type*& __from_next,
00051 extern_type* __to, extern_type* __to_end,
00052 extern_type*& __to_next) const
00053 {
00054 size_t __len = min(__from_end - __from, __to_end - __to);
00055 memcpy(__to, __from, __len);
00056 __from_next = __from;
00057 __to_next = __to;
00058 return noconv;
00059 }
00060
00061 codecvt_base::result
00062
00063 codecvt<char, char, mbstate_t>:: do_unshift(state_type& , extern_type* __to,
00064 extern_type* , extern_type*& __to_next) const
00065 {
00066 __to_next = __to;
00067 return noconv;
00068 }
00069
00070 codecvt_base::result
00071
00072 codecvt<char, char, mbstate_t>:: do_in(state_type& , const extern_type* __from,
00073 const extern_type* __from_end, const extern_type*& __from_next,
00074 intern_type* __to, intern_type* __to_end,
00075 intern_type*& __to_next) const
00076 {
00077 size_t __len = min(__from_end - __from, __to_end - __to);
00078 memcpy(__to, __from, __len);
00079 __from_next = __from;
00080 __to_next = __to;
00081 return noconv;
00082 }
00083
00084 int
00085
00086 codecvt<char, char, mbstate_t>:: do_encoding() const throw()
00087 { return 1; }
00088
00089 bool
00090
00091 codecvt<char, char, mbstate_t>:: do_always_noconv() const throw()
00092 { return true; }
00093
00094 int
00095
00096 codecvt<char, char, mbstate_t>:: do_length (const state_type& , const extern_type* __from,
00097 const extern_type* __end, size_t __max) const
00098 { return min(__max, static_cast<size_t>(__end - __from)); }
00099
00100 int
00101
00102 codecvt<char, char, mbstate_t>:: do_max_length() const throw()
00103 { return 1; }
00104
00105 #ifdef _GLIBCPP_USE_WCHAR_T
00106
00107
00108 codecvt<wchar_t, char, mbstate_t>:: codecvt(size_t __refs)
00109 : __codecvt_abstract_base<wchar_t, char, mbstate_t>(__refs) { }
00110
00111
00112 codecvt<wchar_t, char, mbstate_t>:: ~codecvt() { }
00113
00114 codecvt_base::result
00115
00116 codecvt<wchar_t, char, mbstate_t>:: do_out(state_type& __state, const intern_type* __from,
00117 const intern_type* __from_end, const intern_type*& __from_next,
00118 extern_type* __to, extern_type* __to_end,
00119 extern_type*& __to_next) const
00120 {
00121 result __ret = error;
00122 size_t __len = min(__from_end - __from, __to_end - __to);
00123 size_t __conv = wcsrtombs(__to, &__from, __len, &__state);
00124
00125 if (__conv == __len)
00126 {
00127 __from_next = __from;
00128 __to_next = __to + __conv;
00129 __ret = ok;
00130 }
00131 else if (__conv > 0 && __conv < __len)
00132 {
00133 __from_next = __from;
00134 __to_next = __to + __conv;
00135 __ret = partial;
00136 }
00137 else
00138 __ret = error;
00139
00140 return __ret;
00141 }
00142
00143 codecvt_base::result
00144
00145 codecvt<wchar_t, char, mbstate_t>:: do_unshift(state_type& , extern_type* __to,
00146 extern_type* , extern_type*& __to_next) const
00147 {
00148 __to_next = __to;
00149 return noconv;
00150 }
00151
00152 codecvt_base::result
00153
00154 codecvt<wchar_t, char, mbstate_t>:: do_in(state_type& __state, const extern_type* __from,
00155 const extern_type* __from_end, const extern_type*& __from_next,
00156 intern_type* __to, intern_type* __to_end,
00157 intern_type*& __to_next) const
00158 {
00159 result __ret = error;
00160 size_t __len = min(__from_end - __from, __to_end - __to);
00161 size_t __conv = mbsrtowcs(__to, &__from, __len, &__state);
00162
00163 if (__conv == __len)
00164 {
00165 __from_next = __from;
00166 __to_next = __to + __conv;
00167 __ret = ok;
00168 }
00169 else if (__conv > 0 && __conv < __len)
00170 {
00171 __from_next = __from;
00172 __to_next = __to + __conv;
00173 __ret = partial;
00174 }
00175 else
00176 __ret = error;
00177
00178 return __ret;
00179 }
00180
00181 int
00182
00183 codecvt<wchar_t, char, mbstate_t>:: do_encoding() const throw()
00184 { return 0; }
00185
00186 bool
00187
00188 codecvt<wchar_t, char, mbstate_t>:: do_always_noconv() const throw()
00189 { return false; }
00190
00191 int
00192
00193 codecvt<wchar_t, char, mbstate_t>:: do_length(const state_type& , const extern_type* __from,
00194 const extern_type* __end, size_t __max) const
00195 { return min(__max, static_cast<size_t>(__end - __from)); }
00196
00197 int
00198
00199 codecvt<wchar_t, char, mbstate_t>:: do_max_length() const throw()
00200 { return 1; }
00201 #endif // _GLIBCPP_USE_WCHAR_T
00202
00203 }
00204
00205