#include <locale>
namespace std
{
#ifdef _GLIBCPP_USE___ENC_TRAITS
const int __enc_traits::_S_max_size;
#endif
codecvt<char, char, mbstate_t>::
codecvt(size_t __refs)
: __codecvt_abstract_base<char, char, mbstate_t>(__refs)
{ }
codecvt<char, char, mbstate_t>::
~codecvt() { }
codecvt_base::result
codecvt<char, char, mbstate_t>::
do_out(state_type&, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const
{
size_t __len = min(__from_end - __from, __to_end - __to);
memcpy(__to, __from, __len);
__from_next = __from;
__to_next = __to;
return noconv;
}
codecvt_base::result
codecvt<char, char, mbstate_t>::
do_unshift(state_type&, extern_type* __to,
extern_type*, extern_type*& __to_next) const
{
__to_next = __to;
return noconv;
}
codecvt_base::result
codecvt<char, char, mbstate_t>::
do_in(state_type&, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const
{
size_t __len = min(__from_end - __from, __to_end - __to);
memcpy(__to, __from, __len);
__from_next = __from;
__to_next = __to;
return noconv;
}
int
codecvt<char, char, mbstate_t>::
do_encoding() const throw()
{ return 1; }
bool
codecvt<char, char, mbstate_t>::
do_always_noconv() const throw()
{ return true; }
int
codecvt<char, char, mbstate_t>::
do_length (const state_type&, const extern_type* __from,
const extern_type* __end, size_t __max) const
{ return min(__max, static_cast<size_t>(__end - __from)); }
int
codecvt<char, char, mbstate_t>::
do_max_length() const throw()
{ return 1; }
#ifdef _GLIBCPP_USE_WCHAR_T
codecvt<wchar_t, char, mbstate_t>::
codecvt(size_t __refs)
: __codecvt_abstract_base<wchar_t, char, mbstate_t>(__refs) { }
codecvt<wchar_t, char, mbstate_t>::
~codecvt() { }
codecvt_base::result
codecvt<wchar_t, char, mbstate_t>::
do_out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const
{
result __ret = error;
size_t __len = min(__from_end - __from, __to_end - __to);
size_t __conv = wcsrtombs(__to, &__from, __len, &__state);
if (__conv == __len)
{
__from_next = __from;
__to_next = __to + __conv;
__ret = ok;
}
else if (__conv > 0 && __conv < __len)
{
__from_next = __from;
__to_next = __to + __conv;
__ret = partial;
}
else
__ret = error;
return __ret;
}
codecvt_base::result
codecvt<wchar_t, char, mbstate_t>::
do_unshift(state_type&, extern_type* __to,
extern_type*, extern_type*& __to_next) const
{
__to_next = __to;
return noconv;
}
codecvt_base::result
codecvt<wchar_t, char, mbstate_t>::
do_in(state_type& __state, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const
{
result __ret = error;
size_t __len = min(__from_end - __from, __to_end - __to);
size_t __conv = mbsrtowcs(__to, &__from, __len, &__state);
if (__conv == __len)
{
__from_next = __from;
__to_next = __to + __conv;
__ret = ok;
}
else if (__conv > 0 && __conv < __len)
{
__from_next = __from;
__to_next = __to + __conv;
__ret = partial;
}
else
__ret = error;
return __ret;
}
int
codecvt<wchar_t, char, mbstate_t>::
do_encoding() const throw()
{ return sizeof(wchar_t); }
bool
codecvt<wchar_t, char, mbstate_t>::
do_always_noconv() const throw()
{ return false; }
int
codecvt<wchar_t, char, mbstate_t>::
do_length(const state_type&, const extern_type* __from,
const extern_type* __end, size_t __max) const
{ return min(__max, static_cast<size_t>(__end - __from)); }
int
codecvt<wchar_t, char, mbstate_t>::
do_max_length() const throw()
{ return 1; }
#endif // _GLIBCPP_USE_WCHAR_T
}