1 // 2 // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh) 3 // 4 // Distributed under the Boost Software License, Version 1.0. (See 5 // accompanying file LICENSE_1_0.txt or copy at 6 // http://www.boost.org/LICENSE_1_0.txt) 7 // 8 #define BOOST_LOCALE_SOURCE 9 #include <locale> 10 #include <string> 11 #include <ios> 12 #include <boost/locale/generator.hpp> 13 #include <boost/locale/info.hpp> 14 #include <boost/locale/util.hpp> 15 #include <sstream> 16 #include <stdlib.h> 17 18 #include "locale_data.hpp" 19 20 namespace boost { 21 namespace locale { 22 namespace util { 23 class simple_info : public info { 24 public: simple_info(std::string const & name,size_t refs=0)25 simple_info(std::string const &name,size_t refs = 0) : 26 info(refs), 27 name_(name) 28 { 29 d.parse(name); 30 } get_string_property(string_propery v) const31 virtual std::string get_string_property(string_propery v) const 32 { 33 switch(v) { 34 case language_property: 35 return d.language; 36 case country_property: 37 return d.country; 38 case variant_property: 39 return d.variant; 40 case encoding_property: 41 return d.encoding; 42 case name_property: 43 return name_; 44 default: 45 return ""; 46 }; 47 } 48 get_integer_property(integer_property v) const49 virtual int get_integer_property(integer_property v) const 50 { 51 switch(v) { 52 case utf8_property: 53 return d.utf8; 54 default: 55 return 0; 56 } 57 } 58 private: 59 locale_data d; 60 std::string name_; 61 }; 62 create_info(std::locale const & in,std::string const & name)63 std::locale create_info(std::locale const &in,std::string const &name) 64 { 65 return std::locale(in,new simple_info(name)); 66 } 67 68 69 } // util 70 } // locale 71 } //boost 72 73 74 75 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 76