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
22namespace 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
90
95 void adopt_backend(const std::string& name, localization_backend* backend);
96
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
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
a smart pointer similar to std::unique_ptr but the underlying object has the same constness as the po...
Definition: hold_ptr.hpp:16
Localization backend manager is a class that holds various backend and allows creation of their combi...
Definition: localization_backend.hpp:65
localization_backend_manager()
New empty localization_backend_manager.
static localization_backend_manager global()
localization_backend * create() const
Create new localization backend according to current settings. Ownership is passed to caller.
static localization_backend_manager global(const localization_backend_manager &)
localization_backend_manager(const localization_backend_manager &)
Copy localization_backend_manager.
localization_backend_manager & operator=(const localization_backend_manager &)
Assign localization_backend_manager.
std::unique_ptr< localization_backend > get() const
Create new localization backend according to current settings.
void select(const std::string &backend_name, category_t category=all_categories)
void add_backend(const std::string &name, std::unique_ptr< localization_backend > backend)
std::vector< std::string > get_all_backends() const
Get list of all available backends.
void adopt_backend(const std::string &name, localization_backend *backend)
this class represents a localization backend that can be used for localizing your application.
Definition: localization_backend.hpp:40
virtual localization_backend * clone() const =0
Make a polymorphic copy of the backend.
virtual void clear_options()=0
Clear all options.
virtual std::locale install(const std::locale &base, category_t category, char_facet_t type)=0
Create a facet for category category and character type type.
virtual void set_option(const std::string &name, const std::string &value)=0
Set option for backend, for example "locale" or "encoding".
char_facet_t
Definition: generator.hpp:34
category_t
Definition: generator.hpp:64