CppCMS
|
00001 // 00002 // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh) 00003 // 00004 // Distributed under the Boost Software License, Version 1.0. (See 00005 // accompanying file LICENSE_1_0.txt or copy at 00006 // http://www.boost.org/LICENSE_1_0.txt) 00007 // 00008 #ifndef BOOSTER_LOCALE_LOCALIZATION_BACKEND_HPP 00009 #define BOOSTER_LOCALE_LOCALIZATION_BACKEND_HPP 00010 #include <booster/config.h> 00011 #include <booster/locale/generator.h> 00012 #ifdef BOOSTER_MSVC 00013 # pragma warning(push) 00014 # pragma warning(disable : 4275 4251 4231 4660) 00015 #endif 00016 #include <string> 00017 #include <locale> 00018 #include <vector> 00019 #include <memory> 00020 00021 namespace booster { 00022 namespace locale { 00023 00042 00043 class localization_backend { 00044 localization_backend(localization_backend const &); 00045 void operator=(localization_backend const &); 00046 public: 00047 00048 localization_backend() 00049 { 00050 } 00051 00052 virtual ~localization_backend() 00053 { 00054 } 00055 00059 virtual localization_backend *clone() const = 0; 00060 00064 virtual void set_option(std::string const &name,std::string const &value) = 0; 00065 00069 virtual void clear_options() = 0; 00070 00074 virtual std::locale install(std::locale const &base,locale_category_type category,character_facet_type type = nochar_facet) = 0; 00075 00076 }; // localization_backend 00077 00078 00083 00084 class BOOSTER_API localization_backend_manager { 00085 public: 00089 localization_backend_manager(); 00093 localization_backend_manager(localization_backend_manager const &); 00097 localization_backend_manager const &operator=(localization_backend_manager const &); 00098 00102 ~localization_backend_manager(); 00103 00107 std::auto_ptr<localization_backend> get() const; 00108 00114 void add_backend(std::string const &name,std::auto_ptr<localization_backend> backend); 00115 00119 void remove_all_backends(); 00120 00124 std::vector<std::string> get_all_backends() const; 00125 00130 void select(std::string const &backend_name,locale_category_type category = all_categories); 00131 00137 static localization_backend_manager global(localization_backend_manager const &); 00143 static localization_backend_manager global(); 00144 private: 00145 class impl; 00146 std::auto_ptr<impl> pimpl_; 00147 }; 00148 00149 } // locale 00150 } // boost 00151 00152 00153 #ifdef BOOSTER_MSVC 00154 #pragma warning(pop) 00155 #endif 00156 00157 #endif 00158 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 00159