File indexing completed on 2024-11-15 09:15:14
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_LOCALE_GENERATOR_HPP
0008 #define BOOST_LOCALE_GENERATOR_HPP
0009
0010 #include <boost/locale/hold_ptr.hpp>
0011 #include <cstdint>
0012 #include <locale>
0013 #include <memory>
0014 #include <string>
0015
0016 #ifdef BOOST_MSVC
0017 # pragma warning(push)
0018 # pragma warning(disable : 4275 4251 4231 4660)
0019 #endif
0020
0021 namespace boost {
0022
0023
0024
0025
0026 namespace locale {
0027
0028 class localization_backend;
0029 class localization_backend_manager;
0030
0031
0032
0033
0034 enum class char_facet_t : uint32_t {
0035 nochar = 0,
0036 char_f = 1 << 0,
0037 wchar_f = 1 << 1,
0038 #ifdef __cpp_char8_t
0039 char8_f = 1 << 2,
0040 #endif
0041 #ifdef BOOST_LOCALE_ENABLE_CHAR16_T
0042 char16_f = 1 << 3,
0043 #endif
0044 #ifdef BOOST_LOCALE_ENABLE_CHAR32_T
0045 char32_f = 1 << 4,
0046 #endif
0047 };
0048 typedef BOOST_DEPRECATED("Use char_facet_t") char_facet_t character_facet_type;
0049
0050
0051 constexpr char_facet_t character_facet_first = char_facet_t::char_f;
0052
0053 constexpr char_facet_t character_facet_last =
0054 #ifdef BOOST_LOCALE_ENABLE_CHAR32_T
0055 char_facet_t::char32_f;
0056 #elif defined BOOST_LOCALE_ENABLE_CHAR16_T
0057 char_facet_t::char16_f;
0058 #elif defined __cpp_char8_t
0059 char_facet_t::char8_f;
0060 #else
0061 char_facet_t::wchar_f;
0062 #endif
0063
0064 constexpr char_facet_t all_characters = char_facet_t(0xFFFFFFFFu);
0065
0066
0067
0068
0069 enum class category_t : uint32_t {
0070 convert = 1 << 0,
0071 collation = 1 << 1,
0072 formatting = 1 << 2,
0073 parsing = 1 << 3,
0074 message = 1 << 4,
0075 codepage = 1 << 5,
0076 boundary = 1 << 6,
0077 calendar = 1 << 16,
0078 information = 1 << 17,
0079 };
0080 typedef BOOST_DEPRECATED("Use category_t") category_t locale_category_type;
0081
0082
0083 constexpr category_t per_character_facet_first = category_t::convert;
0084
0085 constexpr category_t per_character_facet_last = category_t::boundary;
0086
0087 constexpr category_t non_character_facet_first = category_t::calendar;
0088
0089 constexpr category_t non_character_facet_last = category_t::information;
0090
0091 constexpr category_t category_first = category_t::convert;
0092
0093 constexpr category_t category_last = category_t::information;
0094
0095 constexpr category_t all_categories = category_t(0xFFFFFFFFu);
0096
0097
0098
0099
0100
0101 class BOOST_LOCALE_DECL generator {
0102 public:
0103
0104 generator();
0105
0106 generator(const localization_backend_manager&);
0107
0108 ~generator();
0109
0110
0111 void categories(category_t cats);
0112
0113 category_t categories() const;
0114
0115
0116 void characters(char_facet_t chars);
0117
0118 char_facet_t characters() const;
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137 void add_messages_domain(const std::string& domain);
0138
0139
0140
0141 void set_default_messages_domain(const std::string& domain);
0142
0143
0144 void clear_domains();
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158 void add_messages_path(const std::string& path);
0159
0160
0161 void clear_paths();
0162
0163
0164 void clear_cache();
0165
0166
0167 void locale_cache_enabled(bool on);
0168
0169
0170 bool locale_cache_enabled() const;
0171
0172
0173 bool use_ansi_encoding() const;
0174
0175
0176
0177
0178
0179
0180 void use_ansi_encoding(bool enc);
0181
0182
0183 std::locale generate(const std::string& id) const;
0184
0185
0186 std::locale generate(const std::locale& base, const std::string& id) const;
0187
0188 std::locale operator()(const std::string& id) const { return generate(id); }
0189
0190 private:
0191 void set_all_options(localization_backend& backend, const std::string& id) const;
0192
0193 generator(const generator&);
0194 void operator=(const generator&);
0195
0196 struct data;
0197 hold_ptr<data> d;
0198 };
0199
0200 constexpr char_facet_t operator|(const char_facet_t lhs, const char_facet_t rhs)
0201 {
0202 return char_facet_t(static_cast<uint32_t>(lhs) | static_cast<uint32_t>(rhs));
0203 }
0204 constexpr char_facet_t operator^(const char_facet_t lhs, const char_facet_t rhs)
0205 {
0206 return char_facet_t(static_cast<uint32_t>(lhs) ^ static_cast<uint32_t>(rhs));
0207 }
0208 constexpr bool operator&(const char_facet_t lhs, const char_facet_t rhs)
0209 {
0210 return (static_cast<uint32_t>(lhs) & static_cast<uint32_t>(rhs)) != 0u;
0211 }
0212
0213 BOOST_CXX14_CONSTEXPR inline char_facet_t& operator++(char_facet_t& v)
0214 {
0215 return v = char_facet_t(static_cast<uint32_t>(v) ? static_cast<uint32_t>(v) << 1 : 1);
0216 }
0217
0218 constexpr category_t operator|(const category_t lhs, const category_t rhs)
0219 {
0220 return category_t(static_cast<uint32_t>(lhs) | static_cast<uint32_t>(rhs));
0221 }
0222 constexpr category_t operator^(const category_t lhs, const category_t rhs)
0223 {
0224 return category_t(static_cast<uint32_t>(lhs) ^ static_cast<uint32_t>(rhs));
0225 }
0226 constexpr bool operator&(const category_t lhs, const category_t rhs)
0227 {
0228 return (static_cast<uint32_t>(lhs) & static_cast<uint32_t>(rhs)) != 0u;
0229 }
0230
0231 BOOST_CXX14_CONSTEXPR inline category_t& operator++(category_t& v)
0232 {
0233 return v = category_t(static_cast<uint32_t>(v) << 1);
0234 }
0235 }
0236 }
0237 #ifdef BOOST_MSVC
0238 # pragma warning(pop)
0239 #endif
0240
0241 #endif