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 <boost/locale/detail/facet_id.hpp>
12#include <locale>
13#include <string>
14
15#ifdef BOOST_MSVC
16# pragma warning(push)
17# pragma warning(disable : 4275 4251 4231 4660)
18#endif
19
20namespace boost { namespace locale {
21
25 class BOOST_SYMBOL_VISIBLE info : public std::locale::facet, public detail::facet_id<info> {
26 public:
33 name_property
34 };
35
38 utf8_property
39 };
40
42 info(size_t refs = 0) : std::locale::facet(refs) {}
44 std::string language() const { return get_string_property(language_property); }
46 std::string country() const { return get_string_property(country_property); }
48 std::string variant() const { return get_string_property(variant_property); }
50 std::string encoding() const { return get_string_property(encoding_property); }
51
53 std::string name() const { return get_string_property(name_property); }
54
56 bool utf8() const { return get_integer_property(utf8_property) != 0; }
57
58 protected:
60 virtual std::string get_string_property(string_propery v) const = 0;
62 virtual int get_integer_property(integer_property v) const = 0;
63 };
64
65}} // namespace boost::locale
66
67#ifdef BOOST_MSVC
68# pragma warning(pop)
69#endif
70
71#endif
a facet that holds general information about locale
Definition: info.hpp:25
bool utf8() const
True if the underlying encoding is UTF-8 (for char streams and strings)
Definition: info.hpp:56
virtual std::string get_string_property(string_propery v) const =0
Get string property by its id v.
std::string variant() const
Get locale variant.
Definition: info.hpp:48
integer_property
Integer information about locale.
Definition: info.hpp:37
info(size_t refs=0)
Standard facet's constructor.
Definition: info.hpp:42
std::string name() const
Get the name of the locale, like en_US.UTF-8.
Definition: info.hpp:53
std::string country() const
Get country name.
Definition: info.hpp:46
string_propery
String information about the locale.
Definition: info.hpp:28
@ encoding_property
encoding name
Definition: info.hpp:32
@ variant_property
Variant for locale.
Definition: info.hpp:31
@ language_property
ISO 639 language id.
Definition: info.hpp:29
@ country_property
ISO 3166 country id.
Definition: info.hpp:30
std::string language() const
Get language name.
Definition: info.hpp:44
std::string encoding() const
Get encoding.
Definition: info.hpp:50
virtual int get_integer_property(integer_property v) const =0
Get integer property by its id v.