Chris@16: // Chris@16: // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: #ifndef BOOST_LOCALE_LOCALIZATION_BACKEND_HPP Chris@16: #define BOOST_LOCALE_LOCALIZATION_BACKEND_HPP Chris@16: #include Chris@16: #include Chris@16: #ifdef BOOST_MSVC Chris@16: # pragma warning(push) Chris@16: # pragma warning(disable : 4275 4251 4231 4660) Chris@16: #endif Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace locale { Chris@16: Chris@16: /// Chris@16: /// \brief this class represents a localization backend that can be used for localizing your application. Chris@16: /// Chris@16: /// Backends are usually registered inside the localization backends manager and allow transparent support Chris@16: /// of different backends, so a user can switch the backend by simply linking the application to the correct one. Chris@16: /// Chris@16: /// Backends may support different tuning options, but these are the default options available to the user Chris@16: /// for all of them Chris@16: /// Chris@16: /// -# \c locale - the name of the locale in POSIX format like en_US.UTF-8 Chris@16: /// -# \c use_ansi_encoding - select system locale using ANSI codepages rather then UTF-8 under Windows Chris@16: /// by default Chris@16: /// -# \c message_path - path to the location of message catalogs (vector of strings) Chris@16: /// -# \c message_application - the name of applications that use message catalogs (vector of strings) Chris@16: /// Chris@16: /// Each backend can be installed with a different default priotiry so when you work with two different backends, you Chris@16: /// can specify priotiry so this backend will be chosen according to their priority. Chris@16: /// Chris@16: Chris@16: class localization_backend { Chris@16: localization_backend(localization_backend const &); Chris@16: void operator=(localization_backend const &); Chris@16: public: Chris@16: Chris@16: localization_backend() Chris@16: { Chris@16: } Chris@16: Chris@16: virtual ~localization_backend() Chris@16: { Chris@16: } Chris@16: Chris@16: /// Chris@16: /// Make a polymorphic copy of the backend Chris@16: /// Chris@16: virtual localization_backend *clone() const = 0; Chris@16: Chris@16: /// Chris@16: /// Set option for backend, for example "locale" or "encoding" Chris@16: /// Chris@16: virtual void set_option(std::string const &name,std::string const &value) = 0; Chris@16: Chris@16: /// Chris@16: /// Clear all options Chris@16: /// Chris@16: virtual void clear_options() = 0; Chris@16: Chris@16: /// Chris@16: /// Create a facet for category \a category and character type \a type Chris@16: /// Chris@16: virtual std::locale install(std::locale const &base,locale_category_type category,character_facet_type type = nochar_facet) = 0; Chris@16: Chris@16: }; // localization_backend Chris@16: Chris@16: Chris@16: /// Chris@16: /// \brief Localization backend manager is a class that holds various backend and allows creation Chris@16: /// of their combination or selection Chris@16: /// Chris@16: Chris@16: class BOOST_LOCALE_DECL localization_backend_manager { Chris@16: public: Chris@16: /// Chris@16: /// New empty localization_backend_manager Chris@16: /// Chris@16: localization_backend_manager(); Chris@16: /// Chris@16: /// Copy localization_backend_manager Chris@16: /// Chris@16: localization_backend_manager(localization_backend_manager const &); Chris@16: /// Chris@16: /// Assign localization_backend_manager Chris@16: /// Chris@16: localization_backend_manager const &operator=(localization_backend_manager const &); Chris@16: Chris@16: /// Chris@16: /// Destructor Chris@16: /// Chris@16: ~localization_backend_manager(); Chris@16: Chris@16: /// Chris@16: /// Create new localization backend according to current settings. Chris@16: /// Chris@16: std::auto_ptr get() const; Chris@16: Chris@16: /// Chris@16: /// Add new backend to the manager, each backend should be uniquely defined by its name. Chris@16: /// Chris@16: /// This library provides: "icu", "posix", "winapi" and "std" backends. Chris@16: /// Chris@16: void add_backend(std::string const &name,std::auto_ptr backend); Chris@16: Chris@16: /// Chris@16: /// Clear backend Chris@16: /// Chris@16: void remove_all_backends(); Chris@16: Chris@16: /// Chris@16: /// Get list of all available backends Chris@16: /// Chris@16: std::vector get_all_backends() const; Chris@16: Chris@16: /// Chris@16: /// Select specific backend by name for a category \a category. It allows combining different Chris@16: /// backends for user preferences. Chris@16: /// Chris@16: void select(std::string const &backend_name,locale_category_type category = all_categories); Chris@16: Chris@16: /// Chris@16: /// Set new global backend manager, the old one is returned. Chris@16: /// Chris@16: /// This function is thread safe Chris@16: /// Chris@16: static localization_backend_manager global(localization_backend_manager const &); Chris@16: /// Chris@16: /// Get global backend manager Chris@16: /// Chris@16: /// This function is thread safe Chris@16: /// Chris@16: static localization_backend_manager global(); Chris@16: private: Chris@16: class impl; Chris@16: std::auto_ptr pimpl_; Chris@16: }; Chris@16: Chris@16: } // locale Chris@16: } // boost Chris@16: Chris@16: Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning(pop) Chris@16: #endif Chris@16: Chris@16: #endif Chris@16: // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 Chris@16: