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