Boost.Locale
info.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_INFO_HPP_INCLUDED
8 #define BOOST_LOCALE_INFO_HPP_INCLUDED
9 
10 #include <boost/locale/config.hpp>
11 #include <locale>
12 #include <string>
13 
14 #ifdef BOOST_MSVC
15 # pragma warning(push)
16 # pragma warning(disable : 4275 4251 4231 4660)
17 #endif
18 
19 namespace boost {
20  namespace locale {
21 
27  class BOOST_LOCALE_DECL info : public std::locale::facet
28  {
29  public:
30  ~info();
31 
32  static std::locale::id id;
33 
42  name_property
43  };
44 
49  utf8_property
50  };
51 
52 
56  info(size_t refs = 0) : std::locale::facet(refs)
57  {
58  }
62  std::string language() const
63  {
64  return get_string_property(language_property);
65  }
69  std::string country() const
70  {
71  return get_string_property(country_property);
72  }
76  std::string variant() const
77  {
78  return get_string_property(variant_property);
79  }
83  std::string encoding() const
84  {
85  return get_string_property(encoding_property);
86  }
87 
91  std::string name() const
92  {
93  return get_string_property(name_property);
94  }
95 
99  bool utf8() const
100  {
101  return get_integer_property(utf8_property) != 0;
102  }
103 
104 #if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
105  std::locale::id& __get_id (void) const { return id; }
106 #endif
107  protected:
111  virtual std::string get_string_property(string_propery v) const = 0;
115  virtual int get_integer_property(integer_property v) const = 0;
116  };
117 
118  }
119 }
120 
121 #ifdef BOOST_MSVC
122 #pragma warning(pop)
123 #endif
124 
125 #endif
126 
std::string country() const
Definition: info.hpp:69
ISO 3166 country id.
Definition: info.hpp:39
std::string language() const
Definition: info.hpp:62
ISO 639 language id.
Definition: info.hpp:38
a facet that holds general information about locale
Definition: info.hpp:27
Variant for locale.
Definition: info.hpp:40
info(size_t refs=0)
Definition: info.hpp:56
bool utf8() const
Definition: info.hpp:99
integer_property
Definition: info.hpp:48
std::string encoding() const
Definition: info.hpp:83
std::string variant() const
Definition: info.hpp:76
string_propery
Definition: info.hpp:37
static std::locale::id id
This member uniquely defines this facet, required by STL.
Definition: info.hpp:32
std::string name() const
Definition: info.hpp:91
encoding name
Definition: info.hpp:41