annotate DEPENDENCIES/generic/include/boost/locale/boundary/boundary_point.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_BOUNDARY_POINT_HPP_INCLUDED
Chris@16 9 #define BOOST_LOCALE_BOUNDARY_BOUNDARY_POINT_HPP_INCLUDED
Chris@16 10
Chris@16 11 #include <boost/locale/boundary/types.hpp>
Chris@16 12
Chris@16 13 namespace boost {
Chris@16 14 namespace locale {
Chris@16 15 namespace boundary {
Chris@16 16
Chris@16 17 ///
Chris@16 18 /// \addtogroup boundary
Chris@16 19 /// @{
Chris@16 20
Chris@16 21 ///
Chris@16 22 /// \brief This class represents a boundary point in the text.
Chris@16 23 ///
Chris@16 24 /// It represents a pair - an iterator and a rule that defines this
Chris@16 25 /// point.
Chris@16 26 ///
Chris@16 27 /// This type of object is dereference by the iterators of boundary_point_index. Using a rule()
Chris@16 28 /// member function you can get the reason why this specific boundary point was selected.
Chris@16 29 ///
Chris@16 30 /// For example, When you use a sentence boundary analysis, the (rule() & \ref sentence_term) != 0 means
Chris@16 31 /// that this boundary point was selected because a sentence terminator (like .?!) was spotted
Chris@16 32 /// and the (rule() & \ref sentence_sep)!=0 means that a separator like line feed or carriage
Chris@16 33 /// return was observed.
Chris@16 34 ///
Chris@16 35 /// \note
Chris@16 36 ///
Chris@16 37 /// - The beginning of analyzed range is always considered a boundary point and its rule is always 0.
Chris@16 38 /// - when using a word boundary analysis the returned rule relates to a chunk of text preceding
Chris@16 39 /// this point.
Chris@16 40 ///
Chris@16 41 /// \see
Chris@16 42 ///
Chris@16 43 /// - \ref boundary_point_index
Chris@16 44 /// - \ref segment
Chris@16 45 /// - \ref segment_index
Chris@16 46 ///
Chris@16 47 template<typename IteratorType>
Chris@16 48 class boundary_point {
Chris@16 49 public:
Chris@16 50 ///
Chris@16 51 /// The type of the base iterator that iterates the original text
Chris@16 52 ///
Chris@16 53 typedef IteratorType iterator_type;
Chris@16 54
Chris@16 55 ///
Chris@16 56 /// Empty default constructor
Chris@16 57 ///
Chris@16 58 boundary_point() : rule_(0) {}
Chris@16 59
Chris@16 60 ///
Chris@16 61 /// Create a new boundary_point using iterator \p and a rule \a r
Chris@16 62 ///
Chris@16 63 boundary_point(iterator_type p,rule_type r) :
Chris@16 64 iterator_(p),
Chris@16 65 rule_(r)
Chris@16 66 {
Chris@16 67 }
Chris@16 68 ///
Chris@16 69 /// Set an new iterator value \a i
Chris@16 70 ///
Chris@16 71 void iterator(iterator_type i)
Chris@16 72 {
Chris@16 73 iterator_ = i;
Chris@16 74 }
Chris@16 75 ///
Chris@16 76 /// Set an new rule value \a r
Chris@16 77 ///
Chris@16 78 void rule(rule_type r)
Chris@16 79 {
Chris@16 80 rule_ = r;
Chris@16 81 }
Chris@16 82 ///
Chris@16 83 /// Fetch an iterator
Chris@16 84 ///
Chris@16 85 iterator_type iterator() const
Chris@16 86 {
Chris@16 87 return iterator_;
Chris@16 88 }
Chris@16 89 ///
Chris@16 90 /// Fetch a rule
Chris@16 91 ///
Chris@16 92 rule_type rule() const
Chris@16 93 {
Chris@16 94 return rule_;
Chris@16 95 }
Chris@16 96 ///
Chris@16 97 /// Check if two boundary points are the same
Chris@16 98 ///
Chris@16 99 bool operator==(boundary_point const &other) const
Chris@16 100 {
Chris@16 101 return iterator_ == other.iterator_ && rule_ = other.rule_;
Chris@16 102 }
Chris@16 103 ///
Chris@16 104 /// Check if two boundary points are different
Chris@16 105 ///
Chris@16 106 bool operator!=(boundary_point const &other) const
Chris@16 107 {
Chris@16 108 return !(*this==other);
Chris@16 109 }
Chris@16 110 ///
Chris@16 111 /// Check if the boundary point points to same location as an iterator \a other
Chris@16 112 ///
Chris@16 113 bool operator==(iterator_type const &other) const
Chris@16 114 {
Chris@16 115 return iterator_ == other;
Chris@16 116 }
Chris@16 117 ///
Chris@16 118 /// Check if the boundary point points to different location from an iterator \a other
Chris@16 119 ///
Chris@16 120 bool operator!=(iterator_type const &other) const
Chris@16 121 {
Chris@16 122 return iterator_ != other;
Chris@16 123 }
Chris@16 124
Chris@16 125 ///
Chris@16 126 /// Automatic cast to the iterator it represents
Chris@16 127 ///
Chris@16 128 operator iterator_type ()const
Chris@16 129 {
Chris@16 130 return iterator_;
Chris@16 131 }
Chris@16 132
Chris@16 133 private:
Chris@16 134 iterator_type iterator_;
Chris@16 135 rule_type rule_;
Chris@16 136
Chris@16 137 };
Chris@16 138 ///
Chris@16 139 /// Check if the boundary point \a r points to same location as an iterator \a l
Chris@16 140 ///
Chris@16 141 template<typename BaseIterator>
Chris@16 142 bool operator==(BaseIterator const &l,boundary_point<BaseIterator> const &r)
Chris@16 143 {
Chris@16 144 return r==l;
Chris@16 145 }
Chris@16 146 ///
Chris@16 147 /// Check if the boundary point \a r points to different location from an iterator \a l
Chris@16 148 ///
Chris@16 149 template<typename BaseIterator>
Chris@16 150 bool operator!=(BaseIterator const &l,boundary_point<BaseIterator> const &r)
Chris@16 151 {
Chris@16 152 return r!=l;
Chris@16 153 }
Chris@16 154
Chris@16 155 /// @}
Chris@16 156
Chris@16 157 typedef boundary_point<std::string::const_iterator> sboundary_point; ///< convenience typedef
Chris@16 158 typedef boundary_point<std::wstring::const_iterator> wsboundary_point; ///< convenience typedef
Chris@16 159 #ifdef BOOST_HAS_CHAR16_T
Chris@16 160 typedef boundary_point<std::u16string::const_iterator> u16sboundary_point;///< convenience typedef
Chris@16 161 #endif
Chris@16 162 #ifdef BOOST_HAS_CHAR32_T
Chris@16 163 typedef boundary_point<std::u32string::const_iterator> u32sboundary_point;///< convenience typedef
Chris@16 164 #endif
Chris@16 165
Chris@16 166 typedef boundary_point<char const *> cboundary_point; ///< convenience typedef
Chris@16 167 typedef boundary_point<wchar_t const *> wcboundary_point; ///< convenience typedef
Chris@16 168 #ifdef BOOST_HAS_CHAR16_T
Chris@16 169 typedef boundary_point<char16_t const *> u16cboundary_point; ///< convenience typedef
Chris@16 170 #endif
Chris@16 171 #ifdef BOOST_HAS_CHAR32_T
Chris@16 172 typedef boundary_point<char32_t const *> u32cboundary_point; ///< convenience typedef
Chris@16 173 #endif
Chris@16 174
Chris@16 175
Chris@16 176 } // boundary
Chris@16 177 } // locale
Chris@16 178 } // boost
Chris@16 179
Chris@16 180
Chris@16 181 #endif
Chris@16 182
Chris@16 183 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4