123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- #ifndef BOOST_LOCALE_GENERATOR_HPP
- #define BOOST_LOCALE_GENERATOR_HPP
- #include <boost/locale/hold_ptr.hpp>
- #include <cstdint>
- #include <locale>
- #include <memory>
- #include <string>
- #ifdef BOOST_MSVC
- # pragma warning(push)
- # pragma warning(disable : 4275 4251 4231 4660)
- #endif
- namespace boost {
- namespace locale {
- class localization_backend;
- class localization_backend_manager;
-
-
-
- enum class char_facet_t : uint32_t {
- nochar = 0,
- char_f = 1 << 0,
- wchar_f = 1 << 1,
- #ifdef __cpp_char8_t
- char8_f = 1 << 2,
- #endif
- #ifdef BOOST_LOCALE_ENABLE_CHAR16_T
- char16_f = 1 << 3,
- #endif
- #ifdef BOOST_LOCALE_ENABLE_CHAR32_T
- char32_f = 1 << 4,
- #endif
- };
- typedef BOOST_DEPRECATED("Use char_facet_t") char_facet_t character_facet_type;
-
- constexpr char_facet_t character_facet_first = char_facet_t::char_f;
-
- constexpr char_facet_t character_facet_last =
- #ifdef BOOST_LOCALE_ENABLE_CHAR32_T
- char_facet_t::char32_f;
- #elif defined BOOST_LOCALE_ENABLE_CHAR16_T
- char_facet_t::char16_f;
- #elif defined __cpp_char8_t
- char_facet_t::char8_f;
- #else
- char_facet_t::wchar_f;
- #endif
-
- constexpr char_facet_t all_characters = char_facet_t(0xFFFFFFFFu);
-
-
-
- enum class category_t : uint32_t {
- convert = 1 << 0,
- collation = 1 << 1,
- formatting = 1 << 2,
- parsing = 1 << 3,
- message = 1 << 4,
- codepage = 1 << 5,
- boundary = 1 << 6,
- calendar = 1 << 16,
- information = 1 << 17,
- };
- typedef BOOST_DEPRECATED("Use category_t") category_t locale_category_type;
-
- constexpr category_t per_character_facet_first = category_t::convert;
-
- constexpr category_t per_character_facet_last = category_t::boundary;
-
- constexpr category_t non_character_facet_first = category_t::calendar;
-
- constexpr category_t non_character_facet_last = category_t::information;
-
- constexpr category_t category_first = category_t::convert;
-
- constexpr category_t category_last = category_t::information;
-
- constexpr category_t all_categories = category_t(0xFFFFFFFFu);
-
-
-
-
- class BOOST_LOCALE_DECL generator {
- public:
-
- generator();
-
- generator(const localization_backend_manager&);
- ~generator();
-
- void categories(category_t cats);
-
- category_t categories() const;
-
- void characters(char_facet_t chars);
-
- char_facet_t characters() const;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void add_messages_domain(const std::string& domain);
-
-
- void set_default_messages_domain(const std::string& domain);
-
- void clear_domains();
-
-
-
-
-
-
-
-
-
-
-
-
- void add_messages_path(const std::string& path);
-
- void clear_paths();
-
- void clear_cache();
-
- void locale_cache_enabled(bool on);
-
- bool locale_cache_enabled() const;
-
- bool use_ansi_encoding() const;
-
-
-
-
-
- void use_ansi_encoding(bool enc);
-
- std::locale generate(const std::string& id) const;
-
-
- std::locale generate(const std::locale& base, const std::string& id) const;
-
- std::locale operator()(const std::string& id) const { return generate(id); }
- private:
- void set_all_options(localization_backend& backend, const std::string& id) const;
- generator(const generator&);
- void operator=(const generator&);
- struct data;
- hold_ptr<data> d;
- };
- constexpr char_facet_t operator|(const char_facet_t lhs, const char_facet_t rhs)
- {
- return char_facet_t(static_cast<uint32_t>(lhs) | static_cast<uint32_t>(rhs));
- }
- constexpr char_facet_t operator^(const char_facet_t lhs, const char_facet_t rhs)
- {
- return char_facet_t(static_cast<uint32_t>(lhs) ^ static_cast<uint32_t>(rhs));
- }
- constexpr bool operator&(const char_facet_t lhs, const char_facet_t rhs)
- {
- return (static_cast<uint32_t>(lhs) & static_cast<uint32_t>(rhs)) != 0u;
- }
-
- BOOST_CXX14_CONSTEXPR inline char_facet_t& operator++(char_facet_t& v)
- {
- return v = char_facet_t(static_cast<uint32_t>(v) ? static_cast<uint32_t>(v) << 1 : 1);
- }
- constexpr category_t operator|(const category_t lhs, const category_t rhs)
- {
- return category_t(static_cast<uint32_t>(lhs) | static_cast<uint32_t>(rhs));
- }
- constexpr category_t operator^(const category_t lhs, const category_t rhs)
- {
- return category_t(static_cast<uint32_t>(lhs) ^ static_cast<uint32_t>(rhs));
- }
- constexpr bool operator&(const category_t lhs, const category_t rhs)
- {
- return (static_cast<uint32_t>(lhs) & static_cast<uint32_t>(rhs)) != 0u;
- }
-
- BOOST_CXX14_CONSTEXPR inline category_t& operator++(category_t& v)
- {
- return v = category_t(static_cast<uint32_t>(v) << 1);
- }
- }
- }
- #ifdef BOOST_MSVC
- # pragma warning(pop)
- #endif
- #endif
|