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 { namespace locale {
24 
41  class BOOST_LOCALE_DECL localization_backend {
42  protected:
44  localization_backend& operator=(const localization_backend&) = default;
45 
46  public:
47  localization_backend() = default;
48  virtual ~localization_backend();
49 
51  virtual localization_backend* clone() const = 0;
52 
54  virtual void set_option(const std::string& name, const std::string& value) = 0;
55 
57  virtual void clear_options() = 0;
58 
60  virtual std::locale install(const std::locale& base, category_t category, char_facet_t type) = 0;
61 
62  }; // localization_backend
63 
66  class BOOST_LOCALE_DECL localization_backend_manager {
67  public:
74 
77 
79  std::unique_ptr<localization_backend> get() const;
80 
81  BOOST_DEPRECATED("This function is deprecated, use 'get()' instead")
82  std::unique_ptr<localization_backend> get_unique_ptr() const { return get(); }
83 
87  void add_backend(const std::string& name, std::unique_ptr<localization_backend> backend);
88 
90  localization_backend* create() const;
91 
96  void adopt_backend(const std::string& name, localization_backend* backend);
97 
99  void remove_all_backends();
100 
102  std::vector<std::string> get_all_backends() const;
103 
106  void select(const std::string& backend_name, category_t category = all_categories);
107 
115  static localization_backend_manager global();
116 
117  private:
118  class impl;
119  hold_ptr<impl> pimpl_;
120  };
121 
122 }} // namespace boost::locale
123 
124 #ifdef BOOST_MSVC
125 # pragma warning(pop)
126 #endif
127 
128 #endif
Localization backend manager is a class that holds various backend and allows creation of their combi...
Definition: localization_backend.hpp:66
category_t
Definition: generator.hpp:64
char_facet_t
Definition: generator.hpp:34
this class represents a localization backend that can be used for localizing your application.
Definition: localization_backend.hpp:41
constexpr category_t all_categories
Generate all of them.
Definition: generator.hpp:90