00001
00002
00003
00004
00005
00006
00007
00008 #ifndef BOOSTER_LOCALE_GENERATOR_HPP
00009 #define BOOSTER_LOCALE_GENERATOR_HPP
00010 #include <booster/config.h>
00011 #include <booster/cstdint.h>
00012 #ifdef BOOSTER_MSVC
00013 # pragma warning(push)
00014 # pragma warning(disable : 4275 4251 4231 4660)
00015 #endif
00016 #include <string>
00017 #include <locale>
00018 #include <memory>
00019
00020 namespace booster {
00021
00022 template<typename Type>
00023 class shared_ptr;
00024
00028 namespace locale {
00029
00030 class localization_backend;
00031 class localization_backend_manager;
00032
00033 static const uint32_t nochar_facet = 0;
00034 static const uint32_t char_facet = 1 << 0;
00035 static const uint32_t wchar_t_facet = 1 << 1;
00036 static const uint32_t char16_t_facet = 1 << 2;
00037 static const uint32_t char32_t_facet = 1 << 3;
00038
00039 static const uint32_t character_first_facet = char_facet;
00040 static const uint32_t character_last_facet = char32_t_facet;
00041 static const uint32_t all_characters = 0xFFFF;
00042
00043 typedef uint32_t character_facet_type;
00044
00045 static const uint32_t convert_facet = 1 << 0;
00046 static const uint32_t collation_facet = 1 << 1;
00047 static const uint32_t formatting_facet= 1 << 2;
00048 static const uint32_t parsing_facet = 1 << 3;
00049 static const uint32_t message_facet = 1 << 4;
00050 static const uint32_t codepage_facet = 1 << 5;
00051 static const uint32_t boundary_facet = 1 << 6;
00052
00053 static const uint32_t per_character_facet_first = convert_facet;
00054 static const uint32_t per_character_facet_last = boundary_facet;
00055
00056 static const uint32_t calendar_facet = 1 << 16;
00057 static const uint32_t information_facet = 1 << 17;
00058
00059 static const uint32_t non_character_facet_first = calendar_facet;
00060 static const uint32_t non_character_facet_last = information_facet;
00061
00062
00063 static const uint32_t all_categories = 0xFFFFFFFFu;
00064
00065 typedef uint32_t locale_category_type;
00066
00073
00074 class BOOSTER_API generator {
00075 public:
00076
00080 generator();
00084 generator(localization_backend_manager const &);
00085
00086 ~generator();
00087
00091 void categories(locale_category_type cats);
00095 locale_category_type categories() const;
00096
00100 void characters(character_facet_type chars);
00104 character_facet_type characters() const;
00105
00126 void add_messages_domain(std::string const &domain);
00131 void set_default_messages_domain(std::string const &domain);
00132
00136 void clear_domains();
00137
00152 void add_messages_path(std::string const &path);
00153
00157 void clear_paths();
00158
00162 void clear_cache();
00163
00167 void locale_cache_enabled(bool on);
00168
00172 bool locale_cache_enabled() const;
00173
00177 bool use_ansi_encoding() const;
00178
00186 void use_ansi_encoding(bool enc);
00187
00191 std::locale generate(std::string const &id) const;
00196 std::locale generate(std::locale const &base,std::string const &id) const;
00200 std::locale operator()(std::string const &id) const
00201 {
00202 return generate(id);
00203 }
00204
00208 void set_option(std::string const &name,std::string const &value);
00209
00213 void clear_options();
00214
00215 private:
00216
00217 void set_all_options(shared_ptr<localization_backend> backend,std::string const &id) const;
00218
00219 generator(generator const &);
00220 void operator=(generator const &);
00221
00222 struct data;
00223 std::auto_ptr<data> d;
00224 };
00225
00226 }
00227 }
00228 #ifdef BOOSTER_MSVC
00229 #pragma warning(pop)
00230 #endif
00231
00232
00233 #endif
00234
00235