Chris@16
|
1 // Boost string_algo library predicate.hpp header file ---------------------------//
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright Pavol Droba 2002-2003.
|
Chris@16
|
4 //
|
Chris@16
|
5 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
6 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8
|
Chris@16
|
9 // See http://www.boost.org/ for updates, documentation, and revision history.
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_STRING_PREDICATE_HPP
|
Chris@16
|
12 #define BOOST_STRING_PREDICATE_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #include <boost/algorithm/string/config.hpp>
|
Chris@16
|
15 #include <boost/range/begin.hpp>
|
Chris@16
|
16 #include <boost/range/end.hpp>
|
Chris@16
|
17 #include <boost/range/iterator.hpp>
|
Chris@16
|
18 #include <boost/range/const_iterator.hpp>
|
Chris@16
|
19 #include <boost/range/as_literal.hpp>
|
Chris@16
|
20 #include <boost/range/iterator_range_core.hpp>
|
Chris@16
|
21
|
Chris@16
|
22 #include <boost/algorithm/string/compare.hpp>
|
Chris@16
|
23 #include <boost/algorithm/string/find.hpp>
|
Chris@16
|
24 #include <boost/algorithm/string/detail/predicate.hpp>
|
Chris@16
|
25
|
Chris@16
|
26 /*! \file boost/algorithm/string/predicate.hpp
|
Chris@16
|
27 Defines string-related predicates.
|
Chris@16
|
28 The predicates determine whether a substring is contained in the input string
|
Chris@16
|
29 under various conditions: a string starts with the substring, ends with the
|
Chris@16
|
30 substring, simply contains the substring or if both strings are equal.
|
Chris@16
|
31 Additionaly the algorithm \c all() checks all elements of a container to satisfy a
|
Chris@16
|
32 condition.
|
Chris@16
|
33
|
Chris@16
|
34 All predicates provide the strong exception guarantee.
|
Chris@16
|
35 */
|
Chris@16
|
36
|
Chris@16
|
37 namespace boost {
|
Chris@16
|
38 namespace algorithm {
|
Chris@16
|
39
|
Chris@16
|
40 // starts_with predicate -----------------------------------------------//
|
Chris@16
|
41
|
Chris@16
|
42 //! 'Starts with' predicate
|
Chris@16
|
43 /*!
|
Chris@16
|
44 This predicate holds when the test string is a prefix of the Input.
|
Chris@16
|
45 In other words, if the input starts with the test.
|
Chris@16
|
46 When the optional predicate is specified, it is used for character-wise
|
Chris@16
|
47 comparison.
|
Chris@16
|
48
|
Chris@16
|
49 \param Input An input sequence
|
Chris@16
|
50 \param Test A test sequence
|
Chris@16
|
51 \param Comp An element comparison predicate
|
Chris@16
|
52 \return The result of the test
|
Chris@16
|
53
|
Chris@16
|
54 \note This function provides the strong exception-safety guarantee
|
Chris@16
|
55 */
|
Chris@16
|
56 template<typename Range1T, typename Range2T, typename PredicateT>
|
Chris@16
|
57 inline bool starts_with(
|
Chris@16
|
58 const Range1T& Input,
|
Chris@16
|
59 const Range2T& Test,
|
Chris@16
|
60 PredicateT Comp)
|
Chris@16
|
61 {
|
Chris@16
|
62 iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input));
|
Chris@16
|
63 iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test));
|
Chris@16
|
64
|
Chris@16
|
65 typedef BOOST_STRING_TYPENAME
|
Chris@16
|
66 range_const_iterator<Range1T>::type Iterator1T;
|
Chris@16
|
67 typedef BOOST_STRING_TYPENAME
|
Chris@16
|
68 range_const_iterator<Range2T>::type Iterator2T;
|
Chris@16
|
69
|
Chris@16
|
70 Iterator1T InputEnd=::boost::end(lit_input);
|
Chris@16
|
71 Iterator2T TestEnd=::boost::end(lit_test);
|
Chris@16
|
72
|
Chris@16
|
73 Iterator1T it=::boost::begin(lit_input);
|
Chris@16
|
74 Iterator2T pit=::boost::begin(lit_test);
|
Chris@16
|
75 for(;
|
Chris@16
|
76 it!=InputEnd && pit!=TestEnd;
|
Chris@16
|
77 ++it,++pit)
|
Chris@16
|
78 {
|
Chris@16
|
79 if( !(Comp(*it,*pit)) )
|
Chris@16
|
80 return false;
|
Chris@16
|
81 }
|
Chris@16
|
82
|
Chris@16
|
83 return pit==TestEnd;
|
Chris@16
|
84 }
|
Chris@16
|
85
|
Chris@16
|
86 //! 'Starts with' predicate
|
Chris@16
|
87 /*!
|
Chris@16
|
88 \overload
|
Chris@16
|
89 */
|
Chris@16
|
90 template<typename Range1T, typename Range2T>
|
Chris@16
|
91 inline bool starts_with(
|
Chris@16
|
92 const Range1T& Input,
|
Chris@16
|
93 const Range2T& Test)
|
Chris@16
|
94 {
|
Chris@16
|
95 return ::boost::algorithm::starts_with(Input, Test, is_equal());
|
Chris@16
|
96 }
|
Chris@16
|
97
|
Chris@16
|
98 //! 'Starts with' predicate ( case insensitive )
|
Chris@16
|
99 /*!
|
Chris@16
|
100 This predicate holds when the test string is a prefix of the Input.
|
Chris@16
|
101 In other words, if the input starts with the test.
|
Chris@16
|
102 Elements are compared case insensitively.
|
Chris@16
|
103
|
Chris@16
|
104 \param Input An input sequence
|
Chris@16
|
105 \param Test A test sequence
|
Chris@16
|
106 \param Loc A locale used for case insensitive comparison
|
Chris@16
|
107 \return The result of the test
|
Chris@16
|
108
|
Chris@16
|
109 \note This function provides the strong exception-safety guarantee
|
Chris@16
|
110 */
|
Chris@16
|
111 template<typename Range1T, typename Range2T>
|
Chris@16
|
112 inline bool istarts_with(
|
Chris@16
|
113 const Range1T& Input,
|
Chris@16
|
114 const Range2T& Test,
|
Chris@16
|
115 const std::locale& Loc=std::locale())
|
Chris@16
|
116 {
|
Chris@16
|
117 return ::boost::algorithm::starts_with(Input, Test, is_iequal(Loc));
|
Chris@16
|
118 }
|
Chris@16
|
119
|
Chris@16
|
120
|
Chris@16
|
121 // ends_with predicate -----------------------------------------------//
|
Chris@16
|
122
|
Chris@16
|
123 //! 'Ends with' predicate
|
Chris@16
|
124 /*!
|
Chris@16
|
125 This predicate holds when the test string is a suffix of the Input.
|
Chris@16
|
126 In other words, if the input ends with the test.
|
Chris@16
|
127 When the optional predicate is specified, it is used for character-wise
|
Chris@16
|
128 comparison.
|
Chris@16
|
129
|
Chris@16
|
130
|
Chris@16
|
131 \param Input An input sequence
|
Chris@16
|
132 \param Test A test sequence
|
Chris@16
|
133 \param Comp An element comparison predicate
|
Chris@16
|
134 \return The result of the test
|
Chris@16
|
135
|
Chris@16
|
136 \note This function provides the strong exception-safety guarantee
|
Chris@16
|
137 */
|
Chris@16
|
138 template<typename Range1T, typename Range2T, typename PredicateT>
|
Chris@16
|
139 inline bool ends_with(
|
Chris@16
|
140 const Range1T& Input,
|
Chris@16
|
141 const Range2T& Test,
|
Chris@16
|
142 PredicateT Comp)
|
Chris@16
|
143 {
|
Chris@16
|
144 iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input));
|
Chris@16
|
145 iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test));
|
Chris@16
|
146
|
Chris@16
|
147 typedef BOOST_STRING_TYPENAME
|
Chris@16
|
148 range_const_iterator<Range1T>::type Iterator1T;
|
Chris@16
|
149 typedef BOOST_STRING_TYPENAME boost::detail::
|
Chris@16
|
150 iterator_traits<Iterator1T>::iterator_category category;
|
Chris@16
|
151
|
Chris@16
|
152 return detail::
|
Chris@16
|
153 ends_with_iter_select(
|
Chris@16
|
154 ::boost::begin(lit_input),
|
Chris@16
|
155 ::boost::end(lit_input),
|
Chris@16
|
156 ::boost::begin(lit_test),
|
Chris@16
|
157 ::boost::end(lit_test),
|
Chris@16
|
158 Comp,
|
Chris@16
|
159 category());
|
Chris@16
|
160 }
|
Chris@16
|
161
|
Chris@16
|
162
|
Chris@16
|
163 //! 'Ends with' predicate
|
Chris@16
|
164 /*!
|
Chris@16
|
165 \overload
|
Chris@16
|
166 */
|
Chris@16
|
167 template<typename Range1T, typename Range2T>
|
Chris@16
|
168 inline bool ends_with(
|
Chris@16
|
169 const Range1T& Input,
|
Chris@16
|
170 const Range2T& Test)
|
Chris@16
|
171 {
|
Chris@16
|
172 return ::boost::algorithm::ends_with(Input, Test, is_equal());
|
Chris@16
|
173 }
|
Chris@16
|
174
|
Chris@16
|
175 //! 'Ends with' predicate ( case insensitive )
|
Chris@16
|
176 /*!
|
Chris@16
|
177 This predicate holds when the test container is a suffix of the Input.
|
Chris@16
|
178 In other words, if the input ends with the test.
|
Chris@16
|
179 Elements are compared case insensitively.
|
Chris@16
|
180
|
Chris@16
|
181 \param Input An input sequence
|
Chris@16
|
182 \param Test A test sequence
|
Chris@16
|
183 \param Loc A locale used for case insensitive comparison
|
Chris@16
|
184 \return The result of the test
|
Chris@16
|
185
|
Chris@16
|
186 \note This function provides the strong exception-safety guarantee
|
Chris@16
|
187 */
|
Chris@16
|
188 template<typename Range1T, typename Range2T>
|
Chris@16
|
189 inline bool iends_with(
|
Chris@16
|
190 const Range1T& Input,
|
Chris@16
|
191 const Range2T& Test,
|
Chris@16
|
192 const std::locale& Loc=std::locale())
|
Chris@16
|
193 {
|
Chris@16
|
194 return ::boost::algorithm::ends_with(Input, Test, is_iequal(Loc));
|
Chris@16
|
195 }
|
Chris@16
|
196
|
Chris@16
|
197 // contains predicate -----------------------------------------------//
|
Chris@16
|
198
|
Chris@16
|
199 //! 'Contains' predicate
|
Chris@16
|
200 /*!
|
Chris@16
|
201 This predicate holds when the test container is contained in the Input.
|
Chris@16
|
202 When the optional predicate is specified, it is used for character-wise
|
Chris@16
|
203 comparison.
|
Chris@16
|
204
|
Chris@16
|
205 \param Input An input sequence
|
Chris@16
|
206 \param Test A test sequence
|
Chris@16
|
207 \param Comp An element comparison predicate
|
Chris@16
|
208 \return The result of the test
|
Chris@16
|
209
|
Chris@16
|
210 \note This function provides the strong exception-safety guarantee
|
Chris@16
|
211 */
|
Chris@16
|
212 template<typename Range1T, typename Range2T, typename PredicateT>
|
Chris@16
|
213 inline bool contains(
|
Chris@16
|
214 const Range1T& Input,
|
Chris@16
|
215 const Range2T& Test,
|
Chris@16
|
216 PredicateT Comp)
|
Chris@16
|
217 {
|
Chris@16
|
218 iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input));
|
Chris@16
|
219 iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test));
|
Chris@16
|
220
|
Chris@16
|
221 if (::boost::empty(lit_test))
|
Chris@16
|
222 {
|
Chris@16
|
223 // Empty range is contained always
|
Chris@16
|
224 return true;
|
Chris@16
|
225 }
|
Chris@16
|
226
|
Chris@16
|
227 // Use the temporary variable to make VACPP happy
|
Chris@16
|
228 bool bResult=(::boost::algorithm::first_finder(lit_test,Comp)(::boost::begin(lit_input), ::boost::end(lit_input)));
|
Chris@16
|
229 return bResult;
|
Chris@16
|
230 }
|
Chris@16
|
231
|
Chris@16
|
232 //! 'Contains' predicate
|
Chris@16
|
233 /*!
|
Chris@16
|
234 \overload
|
Chris@16
|
235 */
|
Chris@16
|
236 template<typename Range1T, typename Range2T>
|
Chris@16
|
237 inline bool contains(
|
Chris@16
|
238 const Range1T& Input,
|
Chris@16
|
239 const Range2T& Test)
|
Chris@16
|
240 {
|
Chris@16
|
241 return ::boost::algorithm::contains(Input, Test, is_equal());
|
Chris@16
|
242 }
|
Chris@16
|
243
|
Chris@16
|
244 //! 'Contains' predicate ( case insensitive )
|
Chris@16
|
245 /*!
|
Chris@16
|
246 This predicate holds when the test container is contained in the Input.
|
Chris@16
|
247 Elements are compared case insensitively.
|
Chris@16
|
248
|
Chris@16
|
249 \param Input An input sequence
|
Chris@16
|
250 \param Test A test sequence
|
Chris@16
|
251 \param Loc A locale used for case insensitive comparison
|
Chris@16
|
252 \return The result of the test
|
Chris@16
|
253
|
Chris@16
|
254 \note This function provides the strong exception-safety guarantee
|
Chris@16
|
255 */
|
Chris@16
|
256 template<typename Range1T, typename Range2T>
|
Chris@16
|
257 inline bool icontains(
|
Chris@16
|
258 const Range1T& Input,
|
Chris@16
|
259 const Range2T& Test,
|
Chris@16
|
260 const std::locale& Loc=std::locale())
|
Chris@16
|
261 {
|
Chris@16
|
262 return ::boost::algorithm::contains(Input, Test, is_iequal(Loc));
|
Chris@16
|
263 }
|
Chris@16
|
264
|
Chris@16
|
265 // equals predicate -----------------------------------------------//
|
Chris@16
|
266
|
Chris@16
|
267 //! 'Equals' predicate
|
Chris@16
|
268 /*!
|
Chris@16
|
269 This predicate holds when the test container is equal to the
|
Chris@16
|
270 input container i.e. all elements in both containers are same.
|
Chris@16
|
271 When the optional predicate is specified, it is used for character-wise
|
Chris@16
|
272 comparison.
|
Chris@16
|
273
|
Chris@16
|
274 \param Input An input sequence
|
Chris@16
|
275 \param Test A test sequence
|
Chris@16
|
276 \param Comp An element comparison predicate
|
Chris@16
|
277 \return The result of the test
|
Chris@16
|
278
|
Chris@16
|
279 \note This is a two-way version of \c std::equal algorithm
|
Chris@16
|
280
|
Chris@16
|
281 \note This function provides the strong exception-safety guarantee
|
Chris@16
|
282 */
|
Chris@16
|
283 template<typename Range1T, typename Range2T, typename PredicateT>
|
Chris@16
|
284 inline bool equals(
|
Chris@16
|
285 const Range1T& Input,
|
Chris@16
|
286 const Range2T& Test,
|
Chris@16
|
287 PredicateT Comp)
|
Chris@16
|
288 {
|
Chris@16
|
289 iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input));
|
Chris@16
|
290 iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test));
|
Chris@16
|
291
|
Chris@16
|
292 typedef BOOST_STRING_TYPENAME
|
Chris@16
|
293 range_const_iterator<Range1T>::type Iterator1T;
|
Chris@16
|
294 typedef BOOST_STRING_TYPENAME
|
Chris@16
|
295 range_const_iterator<Range2T>::type Iterator2T;
|
Chris@16
|
296
|
Chris@16
|
297 Iterator1T InputEnd=::boost::end(lit_input);
|
Chris@16
|
298 Iterator2T TestEnd=::boost::end(lit_test);
|
Chris@16
|
299
|
Chris@16
|
300 Iterator1T it=::boost::begin(lit_input);
|
Chris@16
|
301 Iterator2T pit=::boost::begin(lit_test);
|
Chris@16
|
302 for(;
|
Chris@16
|
303 it!=InputEnd && pit!=TestEnd;
|
Chris@16
|
304 ++it,++pit)
|
Chris@16
|
305 {
|
Chris@16
|
306 if( !(Comp(*it,*pit)) )
|
Chris@16
|
307 return false;
|
Chris@16
|
308 }
|
Chris@16
|
309
|
Chris@16
|
310 return (pit==TestEnd) && (it==InputEnd);
|
Chris@16
|
311 }
|
Chris@16
|
312
|
Chris@16
|
313 //! 'Equals' predicate
|
Chris@16
|
314 /*!
|
Chris@16
|
315 \overload
|
Chris@16
|
316 */
|
Chris@16
|
317 template<typename Range1T, typename Range2T>
|
Chris@16
|
318 inline bool equals(
|
Chris@16
|
319 const Range1T& Input,
|
Chris@16
|
320 const Range2T& Test)
|
Chris@16
|
321 {
|
Chris@16
|
322 return ::boost::algorithm::equals(Input, Test, is_equal());
|
Chris@16
|
323 }
|
Chris@16
|
324
|
Chris@16
|
325 //! 'Equals' predicate ( case insensitive )
|
Chris@16
|
326 /*!
|
Chris@16
|
327 This predicate holds when the test container is equal to the
|
Chris@16
|
328 input container i.e. all elements in both containers are same.
|
Chris@16
|
329 Elements are compared case insensitively.
|
Chris@16
|
330
|
Chris@16
|
331 \param Input An input sequence
|
Chris@16
|
332 \param Test A test sequence
|
Chris@16
|
333 \param Loc A locale used for case insensitive comparison
|
Chris@16
|
334 \return The result of the test
|
Chris@16
|
335
|
Chris@16
|
336 \note This is a two-way version of \c std::equal algorithm
|
Chris@16
|
337
|
Chris@16
|
338 \note This function provides the strong exception-safety guarantee
|
Chris@16
|
339 */
|
Chris@16
|
340 template<typename Range1T, typename Range2T>
|
Chris@16
|
341 inline bool iequals(
|
Chris@16
|
342 const Range1T& Input,
|
Chris@16
|
343 const Range2T& Test,
|
Chris@16
|
344 const std::locale& Loc=std::locale())
|
Chris@16
|
345 {
|
Chris@16
|
346 return ::boost::algorithm::equals(Input, Test, is_iequal(Loc));
|
Chris@16
|
347 }
|
Chris@16
|
348
|
Chris@16
|
349 // lexicographical_compare predicate -----------------------------//
|
Chris@16
|
350
|
Chris@16
|
351 //! Lexicographical compare predicate
|
Chris@16
|
352 /*!
|
Chris@16
|
353 This predicate is an overload of std::lexicographical_compare
|
Chris@16
|
354 for range arguments
|
Chris@16
|
355
|
Chris@16
|
356 It check whether the first argument is lexicographically less
|
Chris@16
|
357 then the second one.
|
Chris@16
|
358
|
Chris@16
|
359 If the optional predicate is specified, it is used for character-wise
|
Chris@16
|
360 comparison
|
Chris@16
|
361
|
Chris@16
|
362 \param Arg1 First argument
|
Chris@16
|
363 \param Arg2 Second argument
|
Chris@16
|
364 \param Pred Comparison predicate
|
Chris@16
|
365 \return The result of the test
|
Chris@16
|
366
|
Chris@16
|
367 \note This function provides the strong exception-safety guarantee
|
Chris@16
|
368 */
|
Chris@16
|
369 template<typename Range1T, typename Range2T, typename PredicateT>
|
Chris@16
|
370 inline bool lexicographical_compare(
|
Chris@16
|
371 const Range1T& Arg1,
|
Chris@16
|
372 const Range2T& Arg2,
|
Chris@16
|
373 PredicateT Pred)
|
Chris@16
|
374 {
|
Chris@16
|
375 iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_arg1(::boost::as_literal(Arg1));
|
Chris@16
|
376 iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_arg2(::boost::as_literal(Arg2));
|
Chris@16
|
377
|
Chris@16
|
378 return std::lexicographical_compare(
|
Chris@16
|
379 ::boost::begin(lit_arg1),
|
Chris@16
|
380 ::boost::end(lit_arg1),
|
Chris@16
|
381 ::boost::begin(lit_arg2),
|
Chris@16
|
382 ::boost::end(lit_arg2),
|
Chris@16
|
383 Pred);
|
Chris@16
|
384 }
|
Chris@16
|
385
|
Chris@16
|
386 //! Lexicographical compare predicate
|
Chris@16
|
387 /*!
|
Chris@16
|
388 \overload
|
Chris@16
|
389 */
|
Chris@16
|
390 template<typename Range1T, typename Range2T>
|
Chris@16
|
391 inline bool lexicographical_compare(
|
Chris@16
|
392 const Range1T& Arg1,
|
Chris@16
|
393 const Range2T& Arg2)
|
Chris@16
|
394 {
|
Chris@16
|
395 return ::boost::algorithm::lexicographical_compare(Arg1, Arg2, is_less());
|
Chris@16
|
396 }
|
Chris@16
|
397
|
Chris@16
|
398 //! Lexicographical compare predicate (case-insensitive)
|
Chris@16
|
399 /*!
|
Chris@16
|
400 This predicate is an overload of std::lexicographical_compare
|
Chris@16
|
401 for range arguments.
|
Chris@16
|
402 It check whether the first argument is lexicographically less
|
Chris@16
|
403 then the second one.
|
Chris@16
|
404 Elements are compared case insensitively
|
Chris@16
|
405
|
Chris@16
|
406
|
Chris@16
|
407 \param Arg1 First argument
|
Chris@16
|
408 \param Arg2 Second argument
|
Chris@16
|
409 \param Loc A locale used for case insensitive comparison
|
Chris@16
|
410 \return The result of the test
|
Chris@16
|
411
|
Chris@16
|
412 \note This function provides the strong exception-safety guarantee
|
Chris@16
|
413 */
|
Chris@16
|
414 template<typename Range1T, typename Range2T>
|
Chris@16
|
415 inline bool ilexicographical_compare(
|
Chris@16
|
416 const Range1T& Arg1,
|
Chris@16
|
417 const Range2T& Arg2,
|
Chris@16
|
418 const std::locale& Loc=std::locale())
|
Chris@16
|
419 {
|
Chris@16
|
420 return ::boost::algorithm::lexicographical_compare(Arg1, Arg2, is_iless(Loc));
|
Chris@16
|
421 }
|
Chris@16
|
422
|
Chris@16
|
423
|
Chris@16
|
424 // all predicate -----------------------------------------------//
|
Chris@16
|
425
|
Chris@16
|
426 //! 'All' predicate
|
Chris@16
|
427 /*!
|
Chris@16
|
428 This predicate holds it all its elements satisfy a given
|
Chris@16
|
429 condition, represented by the predicate.
|
Chris@16
|
430
|
Chris@16
|
431 \param Input An input sequence
|
Chris@16
|
432 \param Pred A predicate
|
Chris@16
|
433 \return The result of the test
|
Chris@16
|
434
|
Chris@16
|
435 \note This function provides the strong exception-safety guarantee
|
Chris@16
|
436 */
|
Chris@16
|
437 template<typename RangeT, typename PredicateT>
|
Chris@16
|
438 inline bool all(
|
Chris@16
|
439 const RangeT& Input,
|
Chris@16
|
440 PredicateT Pred)
|
Chris@16
|
441 {
|
Chris@16
|
442 iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(::boost::as_literal(Input));
|
Chris@16
|
443
|
Chris@16
|
444 typedef BOOST_STRING_TYPENAME
|
Chris@16
|
445 range_const_iterator<RangeT>::type Iterator1T;
|
Chris@16
|
446
|
Chris@16
|
447 Iterator1T InputEnd=::boost::end(lit_input);
|
Chris@16
|
448 for( Iterator1T It=::boost::begin(lit_input); It!=InputEnd; ++It)
|
Chris@16
|
449 {
|
Chris@16
|
450 if (!Pred(*It))
|
Chris@16
|
451 return false;
|
Chris@16
|
452 }
|
Chris@16
|
453
|
Chris@16
|
454 return true;
|
Chris@16
|
455 }
|
Chris@16
|
456
|
Chris@16
|
457 } // namespace algorithm
|
Chris@16
|
458
|
Chris@16
|
459 // pull names to the boost namespace
|
Chris@16
|
460 using algorithm::starts_with;
|
Chris@16
|
461 using algorithm::istarts_with;
|
Chris@16
|
462 using algorithm::ends_with;
|
Chris@16
|
463 using algorithm::iends_with;
|
Chris@16
|
464 using algorithm::contains;
|
Chris@16
|
465 using algorithm::icontains;
|
Chris@16
|
466 using algorithm::equals;
|
Chris@16
|
467 using algorithm::iequals;
|
Chris@16
|
468 using algorithm::all;
|
Chris@16
|
469 using algorithm::lexicographical_compare;
|
Chris@16
|
470 using algorithm::ilexicographical_compare;
|
Chris@16
|
471
|
Chris@16
|
472 } // namespace boost
|
Chris@16
|
473
|
Chris@16
|
474
|
Chris@16
|
475 #endif // BOOST_STRING_PREDICATE_HPP
|