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/generator.hpp>
11 #include <boost/locale/hold_ptr.hpp>
12 #include <locale>
13 #include <memory>
14 #include <string>
15 #include <vector>
16 
17 #ifdef BOOST_MSVC
18 # pragma warning(push)
19 # pragma warning(disable : 4275 4251 4231 4660)
20 #endif
21 
22 namespace boost { namespace locale {
23 
40  class BOOST_LOCALE_DECL localization_backend {
41  protected:
43  localization_backend& operator=(const localization_backend&) = default;
44 
45  public:
46  localization_backend() = default;
47  virtual ~localization_backend();
48 
50  virtual localization_backend* clone() const = 0;
51 
53  virtual void set_option(const std::string& name, const std::string& value) = 0;
54 
56  virtual void clear_options() = 0;
57 
59  virtual std::locale install(const std::locale& base, category_t category, char_facet_t type) = 0;
60 
61  }; // localization_backend
62 
65  class BOOST_LOCALE_DECL localization_backend_manager {
66  public:
73 
76 
78  std::unique_ptr<localization_backend> get() const;
79 
80  BOOST_DEPRECATED("This function is deprecated, use 'get()' instead")
81  std::unique_ptr<localization_backend> get_unique_ptr() const { return get(); }
82 
86  void add_backend(const std::string& name, std::unique_ptr<localization_backend> backend);
87 
89  localization_backend* create() const;
90 
95  void adopt_backend(const std::string& name, localization_backend* backend);
96 
98  void remove_all_backends();
99 
101  std::vector<std::string> get_all_backends() const;
102 
105  void select(const std::string& backend_name, category_t category = all_categories);
106 
114  static localization_backend_manager global();
115 
116  private:
117  class impl;
118  hold_ptr<impl> pimpl_;
119  };
120 
121 }} // namespace boost::locale
122 
123 #ifdef BOOST_MSVC
124 # pragma warning(pop)
125 #endif
126 
127 #endif
Localization backend manager is a class that holds various backend and allows creation of their combi...
Definition: localization_backend.hpp:65
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:40
constexpr category_t all_categories
Generate all of them.
Definition: generator.hpp:90