annotate DEPENDENCIES/generic/include/boost/locale/boundary/facets.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_BOUNDARY_FACETS_HPP_INCLUDED
Chris@16 9 #define BOOST_LOCALE_BOUNDARY_FACETS_HPP_INCLUDED
Chris@16 10
Chris@16 11 #include <boost/locale/config.hpp>
Chris@16 12 #include <boost/locale/boundary/types.hpp>
Chris@16 13 #ifdef BOOST_MSVC
Chris@16 14 # pragma warning(push)
Chris@16 15 # pragma warning(disable : 4275 4251 4231 4660)
Chris@16 16 #endif
Chris@16 17 #include <locale>
Chris@16 18 #include <vector>
Chris@16 19
Chris@16 20
Chris@16 21
Chris@16 22
Chris@16 23 namespace boost {
Chris@16 24
Chris@16 25 namespace locale {
Chris@16 26
Chris@16 27 ///
Chris@16 28 /// \brief This namespae contains all operations required for boundary analysis of text
Chris@16 29 ///
Chris@16 30 namespace boundary {
Chris@16 31 ///
Chris@16 32 /// \addtogroup boundary
Chris@16 33 ///
Chris@16 34 /// @{
Chris@16 35 ///
Chris@16 36
Chris@16 37
Chris@16 38 ///
Chris@16 39 /// \brief This structure is used for representing boundary point
Chris@16 40 /// that follows the offset.
Chris@16 41 ///
Chris@16 42 struct break_info {
Chris@16 43
Chris@16 44 ///
Chris@16 45 /// Create empty break point at beginning
Chris@16 46 ///
Chris@16 47 break_info() :
Chris@16 48 offset(0),
Chris@16 49 rule(0)
Chris@16 50 {
Chris@16 51 }
Chris@16 52 ///
Chris@16 53 /// Create empty break point at offset v.
Chris@16 54 /// it is useful for order comparison with other points.
Chris@16 55 ///
Chris@16 56 break_info(size_t v) :
Chris@16 57 offset(v),
Chris@16 58 rule(0)
Chris@16 59 {
Chris@16 60 }
Chris@16 61
Chris@16 62 ///
Chris@16 63 /// Offset from the beggining of the text where a break occurs.
Chris@16 64 ///
Chris@16 65 size_t offset;
Chris@16 66 ///
Chris@16 67 /// The identification of this break point according to
Chris@16 68 /// various break types
Chris@16 69 ///
Chris@16 70 rule_type rule;
Chris@16 71
Chris@16 72 ///
Chris@16 73 /// Compare two break points' offset. Allows to search with
Chris@16 74 /// standard algorithms over the index.
Chris@16 75 ///
Chris@16 76 bool operator<(break_info const &other) const
Chris@16 77 {
Chris@16 78 return offset < other.offset;
Chris@16 79 }
Chris@16 80 };
Chris@16 81
Chris@16 82 ///
Chris@16 83 /// This type holds the analysis of the text - all its break points
Chris@16 84 /// with marks
Chris@16 85 ///
Chris@16 86 typedef std::vector<break_info> index_type;
Chris@16 87
Chris@16 88
Chris@16 89 template<typename CharType>
Chris@16 90 class boundary_indexing;
Chris@16 91
Chris@16 92 #ifdef BOOST_LOCALE_DOXYGEN
Chris@16 93 ///
Chris@16 94 /// \brief This facet generates an index for boundary analysis
Chris@16 95 /// for a given text.
Chris@16 96 ///
Chris@16 97 /// It is specialized for 4 types of characters \c char_t, \c wchar_t, \c char16_t and \c char32_t
Chris@16 98 ///
Chris@16 99 template<typename Char>
Chris@16 100 class BOOST_LOCALE_DECL boundary_indexing : public std::locale::facet {
Chris@16 101 public:
Chris@16 102 ///
Chris@16 103 /// Default constructor typical for facets
Chris@16 104 ///
Chris@16 105 boundary_indexing(size_t refs=0) : std::locale::facet(refs)
Chris@16 106 {
Chris@16 107 }
Chris@16 108 ///
Chris@16 109 /// Create index for boundary type \a t for text in range [begin,end)
Chris@16 110 ///
Chris@16 111 /// The returned value is an index of type \ref index_type. Note that this
Chris@16 112 /// index is never empty, even if the range [begin,end) is empty it consists
Chris@16 113 /// of at least one boundary point with the offset 0.
Chris@16 114 ///
Chris@16 115 virtual index_type map(boundary_type t,Char const *begin,Char const *end) const = 0;
Chris@16 116 ///
Chris@16 117 /// Identification of this facet
Chris@16 118 ///
Chris@16 119 static std::locale::id id;
Chris@16 120
Chris@16 121 #if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
Chris@16 122 std::locale::id& __get_id (void) const { return id; }
Chris@16 123 #endif
Chris@16 124 };
Chris@16 125
Chris@16 126 #else
Chris@16 127
Chris@16 128 template<>
Chris@16 129 class BOOST_LOCALE_DECL boundary_indexing<char> : public std::locale::facet {
Chris@16 130 public:
Chris@16 131 boundary_indexing(size_t refs=0) : std::locale::facet(refs)
Chris@16 132 {
Chris@16 133 }
Chris@16 134 virtual index_type map(boundary_type t,char const *begin,char const *end) const = 0;
Chris@16 135 static std::locale::id id;
Chris@16 136 #if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
Chris@16 137 std::locale::id& __get_id (void) const { return id; }
Chris@16 138 #endif
Chris@16 139 };
Chris@16 140
Chris@16 141 template<>
Chris@16 142 class BOOST_LOCALE_DECL boundary_indexing<wchar_t> : public std::locale::facet {
Chris@16 143 public:
Chris@16 144 boundary_indexing(size_t refs=0) : std::locale::facet(refs)
Chris@16 145 {
Chris@16 146 }
Chris@16 147 virtual index_type map(boundary_type t,wchar_t const *begin,wchar_t const *end) const = 0;
Chris@16 148
Chris@16 149 static std::locale::id id;
Chris@16 150 #if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
Chris@16 151 std::locale::id& __get_id (void) const { return id; }
Chris@16 152 #endif
Chris@16 153 };
Chris@16 154
Chris@16 155 #ifdef BOOST_HAS_CHAR16_T
Chris@16 156 template<>
Chris@16 157 class BOOST_LOCALE_DECL boundary_indexing<char16_t> : public std::locale::facet {
Chris@16 158 public:
Chris@16 159 boundary_indexing(size_t refs=0) : std::locale::facet(refs)
Chris@16 160 {
Chris@16 161 }
Chris@16 162 virtual index_type map(boundary_type t,char16_t const *begin,char16_t const *end) const = 0;
Chris@16 163 static std::locale::id id;
Chris@16 164 #if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
Chris@16 165 std::locale::id& __get_id (void) const { return id; }
Chris@16 166 #endif
Chris@16 167 };
Chris@16 168 #endif
Chris@16 169
Chris@16 170 #ifdef BOOST_HAS_CHAR32_T
Chris@16 171 template<>
Chris@16 172 class BOOST_LOCALE_DECL boundary_indexing<char32_t> : public std::locale::facet {
Chris@16 173 public:
Chris@16 174 boundary_indexing(size_t refs=0) : std::locale::facet(refs)
Chris@16 175 {
Chris@16 176 }
Chris@16 177 virtual index_type map(boundary_type t,char32_t const *begin,char32_t const *end) const = 0;
Chris@16 178 static std::locale::id id;
Chris@16 179 #if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
Chris@16 180 std::locale::id& __get_id (void) const { return id; }
Chris@16 181 #endif
Chris@16 182 };
Chris@16 183 #endif
Chris@16 184
Chris@16 185 #endif
Chris@16 186
Chris@16 187 ///
Chris@16 188 /// @}
Chris@16 189 ///
Chris@16 190
Chris@16 191
Chris@16 192 } // boundary
Chris@16 193
Chris@16 194 } // locale
Chris@16 195 } // boost
Chris@16 196
Chris@16 197
Chris@16 198 #ifdef BOOST_MSVC
Chris@16 199 #pragma warning(pop)
Chris@16 200 #endif
Chris@16 201
Chris@16 202 #endif
Chris@16 203 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4