annotate DEPENDENCIES/generic/include/boost/locale/generator.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 //
Chris@16 2 // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
Chris@16 3 //
Chris@16 4 // Distributed under the Boost Software License, Version 1.0. (See
Chris@16 5 // accompanying file LICENSE_1_0.txt or copy at
Chris@16 6 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 7 //
Chris@16 8 #ifndef BOOST_LOCALE_GENERATOR_HPP
Chris@16 9 #define BOOST_LOCALE_GENERATOR_HPP
Chris@16 10 #include <boost/locale/config.hpp>
Chris@16 11 #include <boost/cstdint.hpp>
Chris@16 12 #ifdef BOOST_MSVC
Chris@16 13 # pragma warning(push)
Chris@16 14 # pragma warning(disable : 4275 4251 4231 4660)
Chris@16 15 #endif
Chris@16 16 #include <string>
Chris@16 17 #include <locale>
Chris@16 18 #include <memory>
Chris@16 19
Chris@16 20 namespace boost {
Chris@16 21
Chris@16 22 template<typename Type>
Chris@16 23 class shared_ptr;
Chris@16 24
Chris@16 25 ///
Chris@16 26 /// \brief This is the main namespace that encloses all localization classes
Chris@16 27 ///
Chris@16 28 namespace locale {
Chris@16 29
Chris@16 30 class localization_backend;
Chris@16 31 class localization_backend_manager;
Chris@16 32
Chris@16 33 static const uint32_t nochar_facet = 0; ///< Unspecified character category for character independent facets
Chris@16 34 static const uint32_t char_facet = 1 << 0; ///< 8-bit character facets
Chris@16 35 static const uint32_t wchar_t_facet = 1 << 1; ///< wide character facets
Chris@16 36 static const uint32_t char16_t_facet = 1 << 2; ///< C++0x char16_t facets
Chris@16 37 static const uint32_t char32_t_facet = 1 << 3; ///< C++0x char32_t facets
Chris@16 38
Chris@16 39 static const uint32_t character_first_facet = char_facet; ///< First facet specific for character type
Chris@16 40 static const uint32_t character_last_facet = char32_t_facet; ///< Last facet specific for character type
Chris@16 41 static const uint32_t all_characters = 0xFFFF; ///< Special mask -- generate all
Chris@16 42
Chris@16 43 typedef uint32_t character_facet_type; ///<type that specifies the character type that locales can be generated for
Chris@16 44
Chris@16 45 static const uint32_t convert_facet = 1 << 0; ///< Generate conversion facets
Chris@16 46 static const uint32_t collation_facet = 1 << 1; ///< Generate collation facets
Chris@16 47 static const uint32_t formatting_facet= 1 << 2; ///< Generate numbers, currency, date-time formatting facets
Chris@16 48 static const uint32_t parsing_facet = 1 << 3; ///< Generate numbers, currency, date-time formatting facets
Chris@16 49 static const uint32_t message_facet = 1 << 4; ///< Generate message facets
Chris@16 50 static const uint32_t codepage_facet = 1 << 5; ///< Generate character set conversion facets (derived from std::codecvt)
Chris@16 51 static const uint32_t boundary_facet = 1 << 6; ///< Generate boundary analysis facet
Chris@16 52
Chris@16 53 static const uint32_t per_character_facet_first = convert_facet; ///< First facet specific for character
Chris@16 54 static const uint32_t per_character_facet_last = boundary_facet; ///< Last facet specific for character
Chris@16 55
Chris@16 56 static const uint32_t calendar_facet = 1 << 16; ///< Generate boundary analysis facet
Chris@16 57 static const uint32_t information_facet = 1 << 17; ///< Generate general locale information facet
Chris@16 58
Chris@16 59 static const uint32_t non_character_facet_first = calendar_facet; ///< First character independent facet
Chris@16 60 static const uint32_t non_character_facet_last = information_facet;///< Last character independent facet
Chris@16 61
Chris@16 62
Chris@16 63 static const uint32_t all_categories = 0xFFFFFFFFu; ///< Generate all of them
Chris@16 64
Chris@16 65 typedef uint32_t locale_category_type; ///< a type used for more fine grained generation of facets
Chris@16 66
Chris@16 67 ///
Chris@16 68 /// \brief the major class used for locale generation
Chris@16 69 ///
Chris@16 70 /// This class is used for specification of all parameters required for locale generation and
Chris@16 71 /// caching. This class const member functions are thread safe if locale class implementation is thread safe.
Chris@16 72 ///
Chris@16 73
Chris@16 74 class BOOST_LOCALE_DECL generator {
Chris@16 75 public:
Chris@16 76
Chris@16 77 ///
Chris@16 78 /// Create new generator using global localization_backend_manager
Chris@16 79 ///
Chris@16 80 generator();
Chris@16 81 ///
Chris@16 82 /// Create new generator using specific localization_backend_manager
Chris@16 83 ///
Chris@16 84 generator(localization_backend_manager const &);
Chris@16 85
Chris@16 86 ~generator();
Chris@16 87
Chris@16 88 ///
Chris@16 89 /// Set types of facets that should be generated, default all
Chris@16 90 ///
Chris@16 91 void categories(locale_category_type cats);
Chris@16 92 ///
Chris@16 93 /// Get types of facets that should be generated, default all
Chris@16 94 ///
Chris@16 95 locale_category_type categories() const;
Chris@16 96
Chris@16 97 ///
Chris@16 98 /// Set the characters type for which the facets should be generated, default all supported
Chris@16 99 ///
Chris@16 100 void characters(character_facet_type chars);
Chris@16 101 ///
Chris@16 102 /// Get the characters type for which the facets should be generated, default all supported
Chris@16 103 ///
Chris@16 104 character_facet_type characters() const;
Chris@16 105
Chris@16 106 ///
Chris@16 107 /// Add a new domain of messages that would be generated. It should be set in order to enable
Chris@16 108 /// messages support.
Chris@16 109 ///
Chris@16 110 /// Messages domain has following format: "name" or "name/encoding"
Chris@16 111 /// where name is the base name of the "mo" file where the catalog is stored
Chris@16 112 /// without ".mo" extension. For example for file \c /usr/share/locale/he/LC_MESSAGES/blog.mo
Chris@16 113 /// it would be \c blog.
Chris@16 114 ///
Chris@16 115 /// You can optionally specify the encoding of the keys in the sources by adding "/encoding_name"
Chris@16 116 /// For example blog/cp1255.
Chris@16 117 ///
Chris@16 118 /// If not defined all keys are assumed to be UTF-8 encoded.
Chris@16 119 ///
Chris@16 120 /// \note When you select a domain for the program using dgettext or message API, you
Chris@16 121 /// do not specify the encoding part. So for example if the provided
Chris@16 122 /// domain name was "blog/windows-1255" then for translation
Chris@16 123 /// you should use dgettext("blog","Hello")
Chris@16 124 ///
Chris@16 125 ///
Chris@16 126 void add_messages_domain(std::string const &domain);
Chris@16 127 ///
Chris@16 128 /// Set default message domain. If this member was not called, the first added messages domain is used.
Chris@16 129 /// If the domain \a domain is not added yet it is added.
Chris@16 130 ///
Chris@16 131 void set_default_messages_domain(std::string const &domain);
Chris@16 132
Chris@16 133 ///
Chris@16 134 /// Remove all added domains from the list
Chris@16 135 ///
Chris@16 136 void clear_domains();
Chris@16 137
Chris@16 138 ///
Chris@16 139 /// Add a search path where dictionaries are looked in.
Chris@16 140 ///
Chris@16 141 /// \note
Chris@16 142 ///
Chris@16 143 /// - Under the Windows platform the path is treated as a path in the locale's encoding so
Chris@16 144 /// if you create locale "en_US.windows-1251" then path would be treated as cp1255,
Chris@16 145 /// and if it is en_US.UTF-8 it is treated as UTF-8. File name is always opened with
Chris@16 146 /// a wide file name as wide file names are the native file name on Windows.
Chris@16 147 ///
Chris@16 148 /// - Under POSIX platforms all paths passed as-is regardless of encoding as narrow
Chris@16 149 /// encodings are the native encodings for POSIX platforms.
Chris@16 150 ///
Chris@16 151 ///
Chris@16 152 void add_messages_path(std::string const &path);
Chris@16 153
Chris@16 154 ///
Chris@16 155 /// Remove all added paths
Chris@16 156 ///
Chris@16 157 void clear_paths();
Chris@16 158
Chris@16 159 ///
Chris@16 160 /// Remove all cached locales
Chris@16 161 ///
Chris@16 162 void clear_cache();
Chris@16 163
Chris@16 164 ///
Chris@16 165 /// Turn locale caching ON
Chris@16 166 ///
Chris@16 167 void locale_cache_enabled(bool on);
Chris@16 168
Chris@16 169 ///
Chris@16 170 /// Get locale cache option
Chris@16 171 ///
Chris@16 172 bool locale_cache_enabled() const;
Chris@16 173
Chris@16 174 ///
Chris@16 175 /// Check if by default ANSI encoding is selected or UTF-8 onces. The default is false.
Chris@16 176 ///
Chris@16 177 bool use_ansi_encoding() const;
Chris@16 178
Chris@16 179 ///
Chris@16 180 /// Select ANSI encodings as default system encoding rather then UTF-8 by default
Chris@16 181 /// under Windows.
Chris@16 182 ///
Chris@16 183 /// The default is the most portable and most powerful encoding, UTF-8, but the user
Chris@16 184 /// can select "system" one if dealing with legacy applications
Chris@16 185 ///
Chris@16 186 void use_ansi_encoding(bool enc);
Chris@16 187
Chris@16 188 ///
Chris@16 189 /// Generate a locale with id \a id
Chris@16 190 ///
Chris@16 191 std::locale generate(std::string const &id) const;
Chris@16 192 ///
Chris@16 193 /// Generate a locale with id \a id. Use \a base as a locale to which all facets are added,
Chris@16 194 /// instead of std::locale::classic().
Chris@16 195 ///
Chris@16 196 std::locale generate(std::locale const &base,std::string const &id) const;
Chris@16 197 ///
Chris@16 198 /// Shortcut to generate(id)
Chris@16 199 ///
Chris@16 200 std::locale operator()(std::string const &id) const
Chris@16 201 {
Chris@16 202 return generate(id);
Chris@16 203 }
Chris@16 204
Chris@16 205 ///
Chris@16 206 /// Set backend specific option
Chris@16 207 ///
Chris@16 208 void set_option(std::string const &name,std::string const &value);
Chris@16 209
Chris@16 210 ///
Chris@16 211 /// Clear backend specific options
Chris@16 212 ///
Chris@16 213 void clear_options();
Chris@16 214
Chris@16 215 private:
Chris@16 216
Chris@16 217 void set_all_options(shared_ptr<localization_backend> backend,std::string const &id) const;
Chris@16 218
Chris@16 219 generator(generator const &);
Chris@16 220 void operator=(generator const &);
Chris@16 221
Chris@16 222 struct data;
Chris@16 223 std::auto_ptr<data> d;
Chris@16 224 };
Chris@16 225
Chris@16 226 }
Chris@16 227 }
Chris@16 228 #ifdef BOOST_MSVC
Chris@16 229 #pragma warning(pop)
Chris@16 230 #endif
Chris@16 231
Chris@16 232
Chris@16 233 #endif
Chris@16 234 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
Chris@16 235