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 <memory>
19 #include <booster/memory_inc.h>
20 
21 namespace booster {
22 
26  namespace locale {
27 
28  class localization_backend;
29  class localization_backend_manager;
30 
31  static const uint32_t nochar_facet = 0;
32  static const uint32_t char_facet = 1 << 0;
33  static const uint32_t wchar_t_facet = 1 << 1;
34  static const uint32_t char16_t_facet = 1 << 2;
35  static const uint32_t char32_t_facet = 1 << 3;
36 
37  static const uint32_t character_first_facet = char_facet;
38  static const uint32_t character_last_facet = char32_t_facet;
39  static const uint32_t all_characters = 0xFFFF;
40 
41  typedef uint32_t character_facet_type;
42 
43  static const uint32_t convert_facet = 1 << 0;
44  static const uint32_t collation_facet = 1 << 1;
45  static const uint32_t formatting_facet= 1 << 2;
46  static const uint32_t parsing_facet = 1 << 3;
47  static const uint32_t message_facet = 1 << 4;
48  static const uint32_t codepage_facet = 1 << 5;
49  static const uint32_t boundary_facet = 1 << 6;
50 
51  static const uint32_t per_character_facet_first = convert_facet;
52  static const uint32_t per_character_facet_last = boundary_facet;
53 
54  static const uint32_t calendar_facet = 1 << 16;
55  static const uint32_t information_facet = 1 << 17;
56 
57  static const uint32_t non_character_facet_first = calendar_facet;
59 
60 
61  static const uint32_t all_categories = 0xFFFFFFFFu;
62 
63  typedef uint32_t locale_category_type;
64 
71 
72  class BOOSTER_API generator {
73  public:
74 
78  generator();
83 
84  ~generator();
85 
89  void categories(locale_category_type cats);
93  locale_category_type categories() const;
94 
98  void characters(character_facet_type chars);
102  character_facet_type characters() const;
103 
124  void add_messages_domain(std::string const &domain);
129  void set_default_messages_domain(std::string const &domain);
130 
134  void clear_domains();
135 
150  void add_messages_path(std::string const &path);
151 
155  void clear_paths();
156 
160  void clear_cache();
161 
165  void locale_cache_enabled(bool on);
166 
170  bool locale_cache_enabled() const;
171 
175  bool use_ansi_encoding() const;
176 
184  void use_ansi_encoding(bool enc);
185 
189  std::locale generate(std::string const &id) const;
194  std::locale generate(std::locale const &base,std::string const &id) const;
198  std::locale operator()(std::string const &id) const
199  {
200  return generate(id);
201  }
202 
206  void set_option(std::string const &name,std::string const &value);
207 
211  void clear_options();
212 
213  private:
214 
215  void set_all_options(shared_ptr<localization_backend> backend,std::string const &id) const;
216 
217  generator(generator const &);
218  void operator=(generator const &);
219 
220  struct data;
221  std::unique_ptr<data> d;
222  };
223 
224  }
225 }
226 #ifdef BOOSTER_MSVC
227 #pragma warning(pop)
228 #endif
229 
230 
231 #endif
232 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
233 
static const uint32_t collation_facet
Generate collation facets.
Definition: generator.h:44
static const uint32_t all_characters
Special mask – generate all.
Definition: generator.h:39
static const uint32_t information_facet
Generate general locale information facet.
Definition: generator.h:55
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:57
static const uint32_t character_last_facet
Last facet specific for character type.
Definition: generator.h:38
static const uint32_t char32_t_facet
C++0x char32_t facets.
Definition: generator.h:35
uint32_t character_facet_type
type that specifies the character type that locales can be generated for
Definition: generator.h:41
static const uint32_t wchar_t_facet
wide character facets
Definition: generator.h:33
static const uint32_t boundary_facet
Generate boundary analysis facet.
Definition: generator.h:49
uint32_t locale_category_type
a type used for more fine grained generation of facets
Definition: generator.h:63
static const uint32_t per_character_facet_first
First facet specific for character.
Definition: generator.h:51
std::locale operator()(std::string const &id) const
Definition: generator.h:198
static const uint32_t all_categories
Generate all of them.
Definition: generator.h:61
static const uint32_t parsing_facet
Generate numbers, currency, date-time formatting facets.
Definition: generator.h:46
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:72
static const uint32_t calendar_facet
Generate boundary analysis facet.
Definition: generator.h:54
static const uint32_t per_character_facet_last
Last facet specific for character.
Definition: generator.h:52
static const uint32_t char_facet
8-bit character facets
Definition: generator.h:32
static const uint32_t character_first_facet
First facet specific for character type.
Definition: generator.h:37
static const uint32_t non_character_facet_last
Last character independent facet.
Definition: generator.h:58
static const uint32_t char16_t_facet
C++0x char16_t facets.
Definition: generator.h:34
static const uint32_t nochar_facet
Unspecified character category for character independent facets.
Definition: generator.h:31
static const uint32_t convert_facet
Generate conversion facets.
Definition: generator.h:43
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:45
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:47
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:48