2003-09-10 12:32:57 +02:00
|
|
|
#ifndef ARABICA_IMPL_CODECVT_SPECIALISATIONS_H
|
|
|
|
#define ARABICA_IMPL_CODECVT_SPECIALISATIONS_H
|
|
|
|
|
|
|
|
#include <locale>
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
|
|
|
|
template<>
|
2003-09-13 01:15:14 +02:00
|
|
|
class codecvt<char, wchar_t, std::mbstate_t>
|
2003-09-10 12:32:57 +02:00
|
|
|
{
|
|
|
|
protected:
|
2006-05-05 15:19:47 +02:00
|
|
|
virtual ~codecvt() { }
|
2005-08-07 22:16:02 +02:00
|
|
|
|
2003-09-13 01:15:14 +02:00
|
|
|
virtual codecvt_base::result do_out(mbstate_t&,
|
|
|
|
const char* from,
|
|
|
|
const char* from_end,
|
|
|
|
const char*& from_next,
|
|
|
|
wchar_t* to,
|
|
|
|
wchar_t* to_limit,
|
2006-05-05 15:19:47 +02:00
|
|
|
wchar_t*& to_next) const
|
|
|
|
{
|
|
|
|
int limit = std::max<int>(from_end - from, to_limit - to);
|
|
|
|
from_next = from;
|
|
|
|
to_next = to;
|
|
|
|
|
|
|
|
while(limit--)
|
|
|
|
*to_next++ = static_cast<wchar_t>(*from_next++);
|
|
|
|
|
|
|
|
return codecvt_base::ok;
|
|
|
|
} // do_out
|
|
|
|
|
2003-09-13 01:15:14 +02:00
|
|
|
|
|
|
|
virtual codecvt_base::result do_in(mbstate_t&,
|
|
|
|
const wchar_t* from,
|
|
|
|
const wchar_t* from_end,
|
|
|
|
const wchar_t*& from_next,
|
|
|
|
char* to,
|
|
|
|
char* to_limit,
|
2006-05-05 15:19:47 +02:00
|
|
|
char*& to_next) const
|
|
|
|
{
|
|
|
|
int limit = std::max<int>(from_end - from, to_limit - to);
|
|
|
|
from_next = from;
|
|
|
|
to_next = to;
|
|
|
|
|
|
|
|
while(limit--)
|
|
|
|
*to_next++ = static_cast<char>(*from_next++);
|
|
|
|
|
|
|
|
return codecvt_base::ok;
|
|
|
|
} // do_in
|
2003-09-13 01:15:14 +02:00
|
|
|
|
|
|
|
virtual codecvt_base::result do_unshift(mbstate_t&,
|
|
|
|
wchar_t* to,
|
|
|
|
wchar_t* to_limit,
|
2006-05-05 15:19:47 +02:00
|
|
|
wchar_t*& to_next) const
|
|
|
|
{
|
|
|
|
to_next = to;
|
|
|
|
return codecvt_base::noconv;
|
|
|
|
} // do_unshift
|
2003-09-13 01:15:14 +02:00
|
|
|
|
2006-05-05 15:19:47 +02:00
|
|
|
virtual int do_encoding() const throw()
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
} // do_encoding
|
2003-09-13 01:15:14 +02:00
|
|
|
|
2006-05-05 15:19:47 +02:00
|
|
|
virtual bool do_always_noconv() const throw()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
} // do_always_noconv
|
2003-09-10 12:32:57 +02:00
|
|
|
|
|
|
|
virtual int do_length(const mbstate_t&,
|
|
|
|
const wchar_t* from,
|
|
|
|
const wchar_t* end,
|
2003-09-13 01:15:14 +02:00
|
|
|
size_t max) const;
|
2006-05-05 15:19:47 +02:00
|
|
|
{
|
|
|
|
return std::min<int>(max, (end - from));
|
|
|
|
} // do_length
|
2003-09-13 01:15:14 +02:00
|
|
|
|
2006-05-05 15:19:47 +02:00
|
|
|
virtual int do_max_length() const throw()
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
} // do_max_length
|
2003-09-13 01:15:14 +02:00
|
|
|
}; // class codecvt<char, wchar_t, std::mbstate_t> :
|
2003-09-10 12:32:57 +02:00
|
|
|
|
|
|
|
|
2003-09-13 01:15:14 +02:00
|
|
|
} // namespace std
|
2003-09-10 12:32:57 +02:00
|
|
|
#endif
|