Boost.Locale: boost/locale/info.hpp Source File

| Boost.Locale

info.hpp
1//
2// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
3// Copyright (c) 2022-2023 Alexander Grund
4//
5// Distributed under the Boost Software License, Version 1.0.
6// https://www.boost.org/LICENSE_1_0.txt
7
8#ifndef BOOST_LOCALE_INFO_HPP_INCLUDED
9#define BOOST_LOCALE_INFO_HPP_INCLUDED
10
11#include <boost/locale/config.hpp>
12#include <boost/locale/detail/facet_id.hpp>
13#include <locale>
14#include <string>
15
16#ifdef BOOST_MSVC
17# pragma warning(push)
18# pragma warning(disable : 4275 4251 4231 4660)
19#endif
20
21namespace boost { namespace locale {
22
26 class BOOST_SYMBOL_VISIBLE info : public std::locale::facet, public detail::facet_id<info> {
27 public:
29 enum string_property {
30 language_property,
31 country_property,
32 variant_property,
33 encoding_property,
34 name_property
35 };
36
38 enum integer_property {
39 utf8_property
40 };
41
43 info(size_t refs = 0) : std::locale::facet(refs) {}
45 std::string language() const { return get_string_property(language_property); }
47 std::string country() const { return get_string_property(country_property); }
49 std::string variant() const { return get_string_property(variant_property); }
51 std::string encoding() const { return get_string_property(encoding_property); }
52
54 std::string name() const { return get_string_property(name_property); }
55
57 bool utf8() const { return get_integer_property(utf8_property) != 0; }
58
59 protected:
61 virtual std::string get_string_property(string_property v) const = 0;
63 virtual int get_integer_property(integer_property v) const = 0;
64 };
65
66}} // namespace boost::locale
67
68#ifdef BOOST_MSVC
69# pragma warning(pop)
70#endif
71
72#endif
boost::locale::info
a facet that holds general information about locale
Definition: info.hpp:26
boost::locale::info::utf8
bool utf8() const
True if the underlying encoding is UTF-8 (for char streams and strings)
Definition: info.hpp:57
boost::locale::info::variant
std::string variant() const
Get locale variant.
Definition: info.hpp:49
boost::locale::info::integer_property
integer_property
Integer information about locale.
Definition: info.hpp:38
boost::locale::info::info
info(size_t refs=0)
Standard facet's constructor.
Definition: info.hpp:43
boost::locale::info::name
std::string name() const
Get the name of the locale, like en_US.UTF-8.
Definition: info.hpp:54
boost::locale::info::get_string_property
virtual std::string get_string_property(string_property v) const =0
Get string property by its id v.
boost::locale::info::country
std::string country() const
Get country name.
Definition: info.hpp:47
boost::locale::info::string_property
string_property
String information about the locale.
Definition: info.hpp:29
boost::locale::info::encoding_property
@ encoding_property
encoding name
Definition: info.hpp:33
boost::locale::info::variant_property
@ variant_property
Variant for locale.
Definition: info.hpp:32
boost::locale::info::language_property
@ language_property
ISO 639 language id.
Definition: info.hpp:30
boost::locale::info::country_property
@ country_property
ISO 3166 country id.
Definition: info.hpp:31
boost::locale::info::language
std::string language() const
Get language name.
Definition: info.hpp:45
boost::locale::info::encoding
std::string encoding() const
Get encoding.
Definition: info.hpp:51
boost::locale::info::get_integer_property
virtual int get_integer_property(integer_property v) const =0
Get integer property by its id v.
- © Copyright 2009-2012 Artyom Beilis, Distributed under the Boost Software License, Version 1.0.