123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- #ifndef BOOST_LOCALE_UTIL_HPP
- #define BOOST_LOCALE_UTIL_HPP
- #include <boost/locale/generator.hpp>
- #include <boost/locale/utf.hpp>
- #include <boost/assert.hpp>
- #include <cstdint>
- #include <locale>
- #include <memory>
- #include <typeinfo>
- namespace boost { namespace locale {
-
-
- namespace util {
-
-
-
-
-
-
-
-
-
-
- BOOST_LOCALE_DECL
- std::string get_system_locale(bool use_utf8_on_windows = false);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- BOOST_LOCALE_DECL
- std::locale create_info(const std::locale& in, const std::string& name);
-
-
-
-
-
-
-
-
-
-
-
-
- class BOOST_LOCALE_DECL base_converter {
- public:
-
-
-
- static constexpr utf::code_point illegal = utf::illegal;
-
-
- static constexpr utf::code_point incomplete = utf::incomplete;
- virtual ~base_converter();
-
-
- virtual int max_len() const { return 1; }
-
-
-
-
-
-
-
- virtual bool is_thread_safe() const { return false; }
-
- virtual base_converter* clone() const
- {
- BOOST_ASSERT(typeid(*this) == typeid(base_converter));
- return new base_converter();
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- virtual utf::code_point to_unicode(const char*& begin, const char* end)
- {
- if(begin == end)
- return incomplete;
- unsigned char cp = *begin;
- if(cp <= 0x7F) {
- begin++;
- return cp;
- }
- return illegal;
- }
-
-
-
-
-
-
-
-
-
-
- virtual utf::len_or_error from_unicode(utf::code_point u, char* begin, const char* end)
- {
- if(begin == end)
- return incomplete;
- if(u >= 0x80)
- return illegal;
- *begin = static_cast<char>(u);
- return 1;
- }
- };
-
-
- BOOST_LOCALE_DECL std::unique_ptr<base_converter> create_utf8_converter();
- BOOST_DEPRECATED("This function is deprecated, use 'create_utf8_converter()'")
- inline std::unique_ptr<base_converter> create_utf8_converter_unique_ptr()
- {
- return create_utf8_converter();
- }
-
-
-
-
-
- BOOST_LOCALE_DECL std::unique_ptr<base_converter> create_simple_converter(const std::string& encoding);
- BOOST_DEPRECATED("This function is deprecated, use 'create_simple_converter()'")
- inline std::unique_ptr<base_converter> create_simple_converter_unique_ptr(const std::string& encoding)
- {
- return create_simple_converter(encoding);
- }
-
-
-
-
-
-
-
-
-
-
- BOOST_LOCALE_DECL
- std::locale create_codecvt(const std::locale& in, std::unique_ptr<base_converter> cvt, char_facet_t type);
- BOOST_DEPRECATED("This function is deprecated, use 'create_codecvt()'")
- inline std::locale create_codecvt_from_pointer(const std::locale& in, base_converter* cvt, char_facet_t type)
- {
- return create_codecvt(in, std::unique_ptr<base_converter>(cvt), type);
- }
- BOOST_DEPRECATED("This function is deprecated, use 'create_utf8_converter()'")
- BOOST_LOCALE_DECL base_converter* create_utf8_converter_new_ptr();
- BOOST_DEPRECATED("This function is deprecated, use 'create_simple_converter()'")
- BOOST_LOCALE_DECL base_converter* create_simple_converter_new_ptr(const std::string& encoding);
-
-
- BOOST_LOCALE_DECL
- std::locale create_utf8_codecvt(const std::locale& in, char_facet_t type);
-
-
-
-
-
- BOOST_LOCALE_DECL
- std::locale create_simple_codecvt(const std::locale& in, const std::string& encoding, char_facet_t type);
- }
- }}
- #endif
|