Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:44:57

0001 //
0002 // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
0003 // Copyright (c) 2022-2023 Alexander Grund
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 // https://www.boost.org/LICENSE_1_0.txt
0007 
0008 #ifndef BOOST_LOCALE_INFO_HPP_INCLUDED
0009 #define BOOST_LOCALE_INFO_HPP_INCLUDED
0010 
0011 #include <boost/locale/config.hpp>
0012 #include <boost/locale/detail/facet_id.hpp>
0013 #include <locale>
0014 #include <string>
0015 
0016 #ifdef BOOST_MSVC
0017 #    pragma warning(push)
0018 #    pragma warning(disable : 4275 4251 4231 4660)
0019 #endif
0020 
0021 namespace boost { namespace locale {
0022 
0023     /// \brief a facet that holds general information about locale
0024     ///
0025     /// This facet should be always created in order to make all Boost.Locale functions work
0026     class BOOST_SYMBOL_VISIBLE info : public std::locale::facet, public detail::facet_id<info> {
0027     public:
0028         /// String information about the locale
0029         enum string_property {
0030             language_property, ///< ISO 639 language id
0031             country_property,  ///< ISO 3166 country id
0032             variant_property,  ///< Variant for locale
0033             encoding_property, ///< encoding name
0034             name_property      ///< locale name
0035         };
0036 
0037         /// Integer information about locale
0038         enum integer_property {
0039             utf8_property ///< Non zero value if uses UTF-8 encoding
0040         };
0041 
0042         /// Standard facet's constructor
0043         info(size_t refs = 0) : std::locale::facet(refs) {}
0044         /// Get language name
0045         std::string language() const { return get_string_property(language_property); }
0046         /// Get country name
0047         std::string country() const { return get_string_property(country_property); }
0048         /// Get locale variant
0049         std::string variant() const { return get_string_property(variant_property); }
0050         /// Get encoding
0051         std::string encoding() const { return get_string_property(encoding_property); }
0052 
0053         /// Get the name of the locale, like en_US.UTF-8
0054         std::string name() const { return get_string_property(name_property); }
0055 
0056         /// True if the underlying encoding is UTF-8 (for char streams and strings)
0057         bool utf8() const { return get_integer_property(utf8_property) != 0; }
0058 
0059     protected:
0060         /// Get string property by its id \a v
0061         virtual std::string get_string_property(string_property v) const = 0;
0062         /// Get integer property by its id \a v
0063         virtual int get_integer_property(integer_property v) const = 0;
0064     };
0065 
0066 }} // namespace boost::locale
0067 
0068 #ifdef BOOST_MSVC
0069 #    pragma warning(pop)
0070 #endif
0071 
0072 #endif