1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
#include <locale>
#include <stdexcept>
//
//TODO: Check if the GNU libstdc++ std::codecvt template is fixed.
//
// The GNU libstdc++ std::codecvt template is broken for custom types
// but we have to derive from std::codecvt because std::basic_filebuf
// uses has_facet<codecvt<InternT>> and this is using a dynamic_cast.
// Therefore we have to add all custom types at the end of this file.
//
#if defined(__GLIBCXX__) && !defined(CODECVT_NO_GLIBCXX_HACK)
#ifdef _GLIBCXX_NOTHROW
#define CODECVT_NOTHROW _GLIBCXX_NOTHROW
#else
#define CODECVT_NOTHROW throw()
#endif
#define CODECVT_DEFINE_PURE(InternT, ExternT, StateT) \
namespace std { \
template<> \
bool \
codecvt<InternT, ExternT, StateT>::do_always_noconv(void) const CODECVT_NOTHROW\
{ \
throw logic_error("pure virtual method called" \
"std::codecvt<"#InternT", "#ExternT", "#StateT">::do_always_noconv"); \
} \
template<> \
int \
codecvt<InternT, ExternT, StateT>::do_encoding(void) const CODECVT_NOTHROW \
{ \
throw logic_error("pure virtual method called" \
"std::codecvt<"#InternT", "#ExternT", "#StateT">::do_encoding"); \
} \
template<> \
codecvt_base::result \
codecvt<InternT, ExternT, StateT>::do_in(state_type&, \
extern_type const*, extern_type const*, extern_type const*&, \
intern_type*, intern_type*, intern_type*&) const \
{ \
throw logic_error("pure virtual method called" \
"std::codecvt<"#InternT", "#ExternT", "#StateT">::do_in"); \
} \
template<> \
int \
codecvt<InternT, ExternT, StateT>::do_length(state_type&, \
extern_type const*, extern_type const*, size_t) const \
{ \
throw logic_error("pure virtual method called" \
"std::codecvt<"#InternT", "#ExternT", "#StateT">::do_length"); \
} \
template<> \
int \
codecvt<InternT, ExternT, StateT>::do_max_length(void) const CODECVT_NOTHROW \
{ \
throw logic_error("pure virtual method called" \
"std::codecvt<"#InternT", "#ExternT", "#StateT">::do_max_length"); \
} \
template<> \
codecvt_base::result \
codecvt<InternT, ExternT, StateT>::do_out(state_type&, \
intern_type const*, intern_type const*, intern_type const*&, \
extern_type*, extern_type*, extern_type*&) const \
{ \
throw logic_error("pure virtual method called" \
"std::codecvt<"#InternT", "#ExternT", "#StateT">::do_out"); \
} \
template<> \
codecvt_base::result \
codecvt<InternT, ExternT, StateT>::do_unshift(state_type&, \
extern_type*, extern_type*, extern_type*&) const \
{ \
throw logic_error("pure virtual method called" \
"std::codecvt<"#InternT", "#ExternT", "#StateT">::do_unshift"); \
} \
} /* namespace std */
CODECVT_DEFINE_PURE(unsigned char, char, std::mbstate_t)
CODECVT_DEFINE_PURE(unsigned long, char, std::mbstate_t)
#endif /* __GLIBCXX__ && !CODECVT_NO_GLIBCXX_HACK */
| |