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 { namespace locale {
20 
24  class BOOST_LOCALE_DECL info : public std::locale::facet {
25  public:
26  ~info();
27 
28  static std::locale::id id;
29 
36  name_property
37  };
38 
41  utf8_property
42  };
43 
45  info(size_t refs = 0) : std::locale::facet(refs) {}
47  std::string language() const { return get_string_property(language_property); }
49  std::string country() const { return get_string_property(country_property); }
51  std::string variant() const { return get_string_property(variant_property); }
53  std::string encoding() const { return get_string_property(encoding_property); }
54 
56  std::string name() const { return get_string_property(name_property); }
57 
59  bool utf8() const { return get_integer_property(utf8_property) != 0; }
60 
61  protected:
63  virtual std::string get_string_property(string_propery v) const = 0;
65  virtual int get_integer_property(integer_property v) const = 0;
66  };
67 
68 }} // namespace boost::locale
69 
70 #ifdef BOOST_MSVC
71 # pragma warning(pop)
72 #endif
73 
74 #endif
std::string country() const
Get country name.
Definition: info.hpp:49
ISO 3166 country id.
Definition: info.hpp:33
std::string language() const
Get language name.
Definition: info.hpp:47
ISO 639 language id.
Definition: info.hpp:32
a facet that holds general information about locale
Definition: info.hpp:24
Variant for locale.
Definition: info.hpp:34
info(size_t refs=0)
Standard facet's constructor.
Definition: info.hpp:45
bool utf8() const
True if the underlying encoding is UTF-8 (for char streams and strings)
Definition: info.hpp:59
integer_property
Integer information about locale.
Definition: info.hpp:40
std::string encoding() const
Get encoding.
Definition: info.hpp:53
std::string variant() const
Get locale variant.
Definition: info.hpp:51
string_propery
String information about the locale.
Definition: info.hpp:31
static std::locale::id id
This member uniquely defines this facet, required by STL.
Definition: info.hpp:28
std::string name() const
Get the name of the locale, like en_US.UTF-8.
Definition: info.hpp:56
encoding name
Definition: info.hpp:35