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_INFO_H_INCLUDED 00009 #define BOOSTER_LOCALE_INFO_H_INCLUDED 00010 #include <booster/config.h> 00011 #ifdef BOOSTER_MSVC 00012 # pragma warning(push) 00013 # pragma warning(disable : 4275 4251 4231 4660) 00014 #endif 00015 #include <locale> 00016 #include <string> 00017 00018 00019 namespace booster { 00020 namespace locale { 00021 00027 class BOOSTER_API info : public std::locale::facet 00028 { 00029 public: 00030 static std::locale::id id; 00031 00035 enum string_propery { 00036 language_property, 00037 country_property, 00038 variant_property, 00039 encoding_property, 00040 name_property 00041 }; 00042 00046 enum integer_property { 00047 utf8_property 00048 }; 00049 00050 00054 info(size_t refs = 0) : std::locale::facet(refs) 00055 { 00056 } 00060 std::string language() const 00061 { 00062 return get_string_property(language_property); 00063 } 00067 std::string country() const 00068 { 00069 return get_string_property(country_property); 00070 } 00074 std::string variant() const 00075 { 00076 return get_string_property(variant_property); 00077 } 00081 std::string encoding() const 00082 { 00083 return get_string_property(encoding_property); 00084 } 00085 00089 std::string name() const 00090 { 00091 return get_string_property(name_property); 00092 } 00093 00097 bool utf8() const 00098 { 00099 return get_integer_property(utf8_property) != 0; 00100 } 00101 00102 #if defined (__SUNPRO_CC) && defined (_RWSTD_VER) 00103 std::locale::id& __get_id (void) const { return id; } 00104 #endif 00105 protected: 00109 virtual std::string get_string_property(string_propery v) const = 0; 00113 virtual int get_integer_property(integer_property v) const = 0; 00114 }; 00115 00116 } 00117 } 00118 00119 #ifdef BOOSTER_MSVC 00120 #pragma warning(pop) 00121 #endif 00122 00123 #endif 00124 00125 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4