Boost.Locale
localization_backend.hpp
1 //
2 // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
3 //
4 // Distributed under the Boost Software License, Version 1.0.
5 // https://www.boost.org/LICENSE_1_0.txt
6 
7 #ifndef BOOST_LOCALE_LOCALIZATION_BACKEND_HPP
8 #define BOOST_LOCALE_LOCALIZATION_BACKEND_HPP
9 
10 #include <boost/locale/config.hpp>
11 #include <boost/locale/generator.hpp>
12 #include <boost/locale/hold_ptr.hpp>
13 #include <locale>
14 #include <memory>
15 #include <string>
16 #include <vector>
17 
18 #ifdef BOOST_MSVC
19 # pragma warning(push)
20 # pragma warning(disable : 4275 4251 4231 4660)
21 #endif
22 
23 namespace boost {
24  namespace locale {
25 
44 
47  void operator=(localization_backend const &);
48  public:
49 
51 
52  virtual ~localization_backend() {}
53 
57  virtual localization_backend *clone() const = 0;
58 
62  virtual void set_option(std::string const &name,std::string const &value) = 0;
63 
67  virtual void clear_options() = 0;
68 
72  virtual std::locale install(std::locale const &base,locale_category_type category,character_facet_type type = nochar_facet) = 0;
73 
74  }; // localization_backend
75 
76 
81 
82  class BOOST_LOCALE_DECL localization_backend_manager {
83  public:
96 
101 
102  #if BOOST_LOCALE_USE_AUTO_PTR
103  std::auto_ptr<localization_backend> get() const;
107 
113  void add_backend(std::string const &name,std::auto_ptr<localization_backend> backend);
114  #endif
115 
119  localization_backend *create() const;
126  void adopt_backend(std::string const &name,localization_backend *backend);
127  #ifndef BOOST_NO_CXX11_SMART_PTR
128  std::unique_ptr<localization_backend> get_unique_ptr() const;
132 
138  void add_backend(std::string const &name,std::unique_ptr<localization_backend> backend);
139  #endif
140 
144  void remove_all_backends();
145 
149  std::vector<std::string> get_all_backends() const;
150 
155  void select(std::string const &backend_name,locale_category_type category = all_categories);
156 
168  static localization_backend_manager global();
169  private:
170  class impl;
171  hold_ptr<impl> pimpl_;
172  };
173 
174  } // locale
175 } // boost
176 
177 
178 #ifdef BOOST_MSVC
179 #pragma warning(pop)
180 #endif
181 
182 #endif
183 
Localization backend manager is a class that holds various backend and allows creation of their combi...
Definition: localization_backend.hpp:82
virtual std::locale install(std::locale const &base, locale_category_type category, character_facet_type type=nochar_facet)=0
static const uint32_t nochar_facet
Unspecified character category for character independent facets.
Definition: generator.hpp:31
uint32_t character_facet_type
type that specifies the character type that locales can be generated for
Definition: generator.hpp:41
virtual localization_backend * clone() const =0
this class represents a localization backend that can be used for localizing your application.
Definition: localization_backend.hpp:45
uint32_t locale_category_type
a type used for more fine grained generation of facets
Definition: generator.hpp:63
static const uint32_t all_categories
Generate all of them.
Definition: generator.hpp:61
virtual void set_option(std::string const &name, std::string const &value)=0