Boost.Locale
generator.hpp
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 BOOST_LOCALE_GENERATOR_HPP
9 #define BOOST_LOCALE_GENERATOR_HPP
10 #include <boost/locale/config.hpp>
11 #include <boost/cstdint.hpp>
12 #ifdef BOOST_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 
20 namespace boost {
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 BOOST_LOCALE_DECL 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 BOOST_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 boundary_facet
Generate boundary analysis facet.
Definition: generator.hpp:51
static const uint32_t non_character_facet_first
First character independent facet.
Definition: generator.hpp:59
the facet that generates calendar for specific locale
Definition: date_time_facet.hpp:234
Localization backend manager is a class that holds various backend and allows creation of their combi...
Definition: localization_backend.hpp:84
static const uint32_t parsing_facet
Generate numbers, currency, date-time formatting facets.
Definition: generator.hpp:48
static const uint32_t nochar_facet
Unspecified character category for character independent facets.
Definition: generator.hpp:33
uint32_t character_facet_type
type that specifies the character type that locales can be generated for
Definition: generator.hpp:43
static const uint32_t formatting_facet
Generate numbers, currency, date-time formatting facets.
Definition: generator.hpp:47
static const uint32_t convert_facet
Generate conversion facets.
Definition: generator.hpp:45
std::locale operator()(std::string const &id) const
Definition: generator.hpp:200
static const uint32_t per_character_facet_last
Last facet specific for character.
Definition: generator.hpp:54
Definition: generator.hpp:23
static const uint32_t calendar_facet
Generate boundary analysis facet.
Definition: generator.hpp:56
static const uint32_t message_facet
Generate message facets.
Definition: generator.hpp:49
static const uint32_t codepage_facet
Generate character set conversion facets (derived from std::codecvt)
Definition: generator.hpp:50
static const uint32_t per_character_facet_first
First facet specific for character.
Definition: generator.hpp:53
static const uint32_t character_last_facet
Last facet specific for character type.
Definition: generator.hpp:40
static const uint32_t character_first_facet
First facet specific for character type.
Definition: generator.hpp:39
static const uint32_t collation_facet
Generate collation facets.
Definition: generator.hpp:46
static const uint32_t non_character_facet_last
Last character independent facet.
Definition: generator.hpp:60
static const uint32_t char16_t_facet
C++0x char16_t facets.
Definition: generator.hpp:36
unspecified_type domain(std::string const &id)
Definition: message.hpp:789
static const uint32_t char32_t_facet
C++0x char32_t facets.
Definition: generator.hpp:37
uint32_t locale_category_type
a type used for more fine grained generation of facets
Definition: generator.hpp:65
static const uint32_t information_facet
Generate general locale information facet.
Definition: generator.hpp:57
the major class used for locale generation
Definition: generator.hpp:74
static const uint32_t char_facet
8-bit character facets
Definition: generator.hpp:34
static const uint32_t all_categories
Generate all of them.
Definition: generator.hpp:63
static const uint32_t wchar_t_facet
wide character facets
Definition: generator.hpp:35
static const uint32_t all_characters
Special mask – generate all.
Definition: generator.hpp:41