CppCMS
generator.h
1 //
2 // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 #ifndef BOOSTER_LOCALE_GENERATOR_HPP
9 #define BOOSTER_LOCALE_GENERATOR_HPP
10 #include <booster/config.h>
11 #include <booster/cstdint.h>
12 #ifdef BOOSTER_MSVC
13 # pragma warning(push)
14 # pragma warning(disable : 4275 4251 4231 4660)
15 #endif
16 #include <string>
17 #include <locale>
18 #include <booster/auto_ptr_inc.h>
19 
20 namespace booster {
21 
22  template<typename Type>
23  class shared_ptr;
24 
28  namespace locale {
29 
30  class localization_backend;
31  class localization_backend_manager;
32 
33  static const uint32_t nochar_facet = 0;
34  static const uint32_t char_facet = 1 << 0;
35  static const uint32_t wchar_t_facet = 1 << 1;
36  static const uint32_t char16_t_facet = 1 << 2;
37  static const uint32_t char32_t_facet = 1 << 3;
38 
39  static const uint32_t character_first_facet = char_facet;
40  static const uint32_t character_last_facet = char32_t_facet;
41  static const uint32_t all_characters = 0xFFFF;
42 
43  typedef uint32_t character_facet_type;
44 
45  static const uint32_t convert_facet = 1 << 0;
46  static const uint32_t collation_facet = 1 << 1;
47  static const uint32_t formatting_facet= 1 << 2;
48  static const uint32_t parsing_facet = 1 << 3;
49  static const uint32_t message_facet = 1 << 4;
50  static const uint32_t codepage_facet = 1 << 5;
51  static const uint32_t boundary_facet = 1 << 6;
52 
53  static const uint32_t per_character_facet_first = convert_facet;
54  static const uint32_t per_character_facet_last = boundary_facet;
55 
56  static const uint32_t calendar_facet = 1 << 16;
57  static const uint32_t information_facet = 1 << 17;
58 
59  static const uint32_t non_character_facet_first = calendar_facet;
61 
62 
63  static const uint32_t all_categories = 0xFFFFFFFFu;
64 
65  typedef uint32_t locale_category_type;
66 
73 
74  class BOOSTER_API generator {
75  public:
76 
80  generator();
85 
86  ~generator();
87 
91  void categories(locale_category_type cats);
95  locale_category_type categories() const;
96 
100  void characters(character_facet_type chars);
104  character_facet_type characters() const;
105 
126  void add_messages_domain(std::string const &domain);
131  void set_default_messages_domain(std::string const &domain);
132 
136  void clear_domains();
137 
152  void add_messages_path(std::string const &path);
153 
157  void clear_paths();
158 
162  void clear_cache();
163 
167  void locale_cache_enabled(bool on);
168 
172  bool locale_cache_enabled() const;
173 
177  bool use_ansi_encoding() const;
178 
186  void use_ansi_encoding(bool enc);
187 
191  std::locale generate(std::string const &id) const;
196  std::locale generate(std::locale const &base,std::string const &id) const;
200  std::locale operator()(std::string const &id) const
201  {
202  return generate(id);
203  }
204 
208  void set_option(std::string const &name,std::string const &value);
209 
213  void clear_options();
214 
215  private:
216 
217  void set_all_options(shared_ptr<localization_backend> backend,std::string const &id) const;
218 
219  generator(generator const &);
220  void operator=(generator const &);
221 
222  struct data;
223  std::auto_ptr<data> d;
224  };
225 
226  }
227 }
228 #ifdef BOOSTER_MSVC
229 #pragma warning(pop)
230 #endif
231 
232 
233 #endif
234 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
235 
static const uint32_t collation_facet
Generate collation facets.
Definition: generator.h:46
static const uint32_t all_characters
Special mask – generate all.
Definition: generator.h:41
static const uint32_t information_facet
Generate general locale information facet.
Definition: generator.h:57
details::set_domain domain(std::string const &id)
Definition: message.h:789
static const uint32_t non_character_facet_first
First character independent facet.
Definition: generator.h:59
static const uint32_t character_last_facet
Last facet specific for character type.
Definition: generator.h:40
static const uint32_t char32_t_facet
C++0x char32_t facets.
Definition: generator.h:37
uint32_t character_facet_type
type that specifies the character type that locales can be generated for
Definition: generator.h:43
static const uint32_t wchar_t_facet
wide character facets
Definition: generator.h:35
static const uint32_t boundary_facet
Generate boundary analysis facet.
Definition: generator.h:51
uint32_t locale_category_type
a type used for more fine grained generation of facets
Definition: generator.h:65
static const uint32_t per_character_facet_first
First facet specific for character.
Definition: generator.h:53
std::locale operator()(std::string const &id) const
Definition: generator.h:200
static const uint32_t all_categories
Generate all of them.
Definition: generator.h:63
Definition: log.h:25
static const uint32_t parsing_facet
Generate numbers, currency, date-time formatting facets.
Definition: generator.h:48
This is the main namespace that encloses all localization classes.
Definition: locale_fwd.h:14
the major class used for locale generation
Definition: generator.h:74
static const uint32_t calendar_facet
Generate boundary analysis facet.
Definition: generator.h:56
static const uint32_t per_character_facet_last
Last facet specific for character.
Definition: generator.h:54
static const uint32_t char_facet
8-bit character facets
Definition: generator.h:34
static const uint32_t character_first_facet
First facet specific for character type.
Definition: generator.h:39
static const uint32_t non_character_facet_last
Last character independent facet.
Definition: generator.h:60
static const uint32_t char16_t_facet
C++0x char16_t facets.
Definition: generator.h:36
static const uint32_t nochar_facet
Unspecified character category for character independent facets.
Definition: generator.h:33
static const uint32_t convert_facet
Generate conversion facets.
Definition: generator.h:45
Localization backend manager is a class that holds various backend and allows creation of their combi...
Definition: localization_backend.h:84
static const uint32_t formatting_facet
Generate numbers, currency, date-time formatting facets.
Definition: generator.h:47
Booster library namespace. The library that implements Boost Like API in ABI backward compatible way...
Definition: application.h:23
static const uint32_t message_facet
Generate message facets.
Definition: generator.h:49
the facet that generates calendar for specific locale
Definition: date_time_facet.h:234
static const uint32_t codepage_facet
Generate character set conversion facets (derived from std::codecvt)
Definition: generator.h:50