| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | //  Boost string_algo library predicate.hpp header file  ---------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-27 10:27:37 +00:00
										 |  |  | //  Copyright Pavol Droba 2002-2003.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Distributed under the Boost Software License, Version 1.0.
 | 
					
						
							|  |  |  | //    (See accompanying file LICENSE_1_0.txt or copy at
 | 
					
						
							|  |  |  | //          http://www.boost.org/LICENSE_1_0.txt)
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-27 10:27:37 +00:00
										 |  |  | //  See http://www.boost.org/ for updates, documentation, and revision history.
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifndef BOOST_STRING_PREDICATE_HPP
 | 
					
						
							|  |  |  | #define BOOST_STRING_PREDICATE_HPP
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <boost/algorithm/string/config.hpp>
 | 
					
						
							| 
									
										
										
										
											2005-01-21 16:45:29 +00:00
										 |  |  | #include <boost/range/begin.hpp>
 | 
					
						
							|  |  |  | #include <boost/range/end.hpp>
 | 
					
						
							|  |  |  | #include <boost/range/iterator.hpp>
 | 
					
						
							|  |  |  | #include <boost/range/const_iterator.hpp>
 | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  | #include <boost/range/as_literal.hpp>
 | 
					
						
							|  |  |  | #include <boost/range/iterator_range.hpp>
 | 
					
						
							| 
									
										
										
										
											2005-01-21 16:45:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | #include <boost/algorithm/string/compare.hpp>
 | 
					
						
							|  |  |  | #include <boost/algorithm/string/find.hpp>
 | 
					
						
							|  |  |  | #include <boost/algorithm/string/detail/predicate.hpp>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*! \file boost/algorithm/string/predicate.hpp
 | 
					
						
							|  |  |  |     Defines string-related predicates.  | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |     The predicates determine whether a substring is contained in the input string  | 
					
						
							|  |  |  |     under various conditions: a string starts with the substring, ends with the  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |     substring, simply contains the substring or if both strings are equal. | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |     Additionaly the algorithm \c all() checks all elements of a container to satisfy a  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |     condition. | 
					
						
							| 
									
										
										
										
											2004-07-14 21:28:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |     All predicates provide the strong exception guarantee. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace boost { | 
					
						
							|  |  |  |     namespace algorithm { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //  starts_with predicate  -----------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! 'Starts with' predicate
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             This predicate holds when the test string is a prefix of the Input. | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             In other words, if the input starts with the test. | 
					
						
							|  |  |  |             When the optional predicate is specified, it is used for character-wise | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             comparison. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             \param Input An input sequence | 
					
						
							|  |  |  |             \param Test A test sequence | 
					
						
							|  |  |  |             \param Comp An element comparison predicate | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \return The result of the test | 
					
						
							| 
									
										
										
										
											2004-07-14 21:28:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-16 09:06:39 +00:00
										 |  |  |               \note This function provides the strong exception-safety guarantee | 
					
						
							|  |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename Range1T, typename Range2T, typename PredicateT> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             inline bool starts_with(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             const Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Test, | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             PredicateT Comp) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input)); | 
					
						
							|  |  |  |             iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test)); | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             typedef BOOST_STRING_TYPENAME  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 range_const_iterator<Range1T>::type Iterator1T; | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             typedef BOOST_STRING_TYPENAME  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 range_const_iterator<Range2T>::type Iterator2T; | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-17 21:04:00 +00:00
										 |  |  |             Iterator1T InputEnd=::boost::end(lit_input); | 
					
						
							|  |  |  |             Iterator2T TestEnd=::boost::end(lit_test); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-17 21:04:00 +00:00
										 |  |  |             Iterator1T it=::boost::begin(lit_input); | 
					
						
							|  |  |  |             Iterator2T pit=::boost::begin(lit_test); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             for(; | 
					
						
							|  |  |  |                 it!=InputEnd && pit!=TestEnd; | 
					
						
							|  |  |  |                 ++it,++pit) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 if( !(Comp(*it,*pit)) ) | 
					
						
							|  |  |  |                     return false; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             return pit==TestEnd; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! 'Starts with' predicate
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \overload | 
					
						
							|  |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename Range1T, typename Range2T> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline bool starts_with(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             const Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Test) | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::starts_with(Input, Test, is_equal()); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! 'Starts with' predicate ( case insensitive )
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             This predicate holds when the test string is a prefix of the Input. | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             In other words, if the input starts with the test. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             Elements are compared case insensitively. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             \param Input An input sequence | 
					
						
							|  |  |  |             \param Test A test sequence | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \param Loc A locale used for case insensitive comparison | 
					
						
							|  |  |  |             \return The result of the test | 
					
						
							| 
									
										
										
										
											2004-07-14 21:28:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-16 09:06:39 +00:00
										 |  |  |             \note This function provides the strong exception-safety guarantee | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename Range1T, typename Range2T> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline bool istarts_with(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             const Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Test, | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             const std::locale& Loc=std::locale()) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::starts_with(Input, Test, is_iequal(Loc)); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //  ends_with predicate  -----------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! 'Ends with' predicate
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             This predicate holds when the test string is a suffix of the Input. | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             In other words, if the input ends with the test. | 
					
						
							|  |  |  |             When the optional predicate is specified, it is used for character-wise | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             comparison. | 
					
						
							| 
									
										
										
										
											2004-07-06 21:28:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             \param Input An input sequence | 
					
						
							|  |  |  |             \param Test A test sequence | 
					
						
							|  |  |  |             \param Comp An element comparison predicate | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \return The result of the test | 
					
						
							| 
									
										
										
										
											2004-07-14 21:28:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-16 09:06:39 +00:00
										 |  |  |               \note This function provides the strong exception-safety guarantee | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename Range1T, typename Range2T, typename PredicateT> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline bool ends_with(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             const Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Test, | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             PredicateT Comp) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input)); | 
					
						
							|  |  |  |             iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test)); | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             typedef BOOST_STRING_TYPENAME  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 range_const_iterator<Range1T>::type Iterator1T; | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             typedef BOOST_STRING_TYPENAME boost::detail:: | 
					
						
							|  |  |  |                 iterator_traits<Iterator1T>::iterator_category category; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             return detail:: | 
					
						
							|  |  |  |                 ends_with_iter_select(  | 
					
						
							| 
									
										
										
										
											2008-06-17 21:04:00 +00:00
										 |  |  |                     ::boost::begin(lit_input),  | 
					
						
							|  |  |  |                     ::boost::end(lit_input),  | 
					
						
							|  |  |  |                     ::boost::begin(lit_test),  | 
					
						
							|  |  |  |                     ::boost::end(lit_test),  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |                     Comp, | 
					
						
							|  |  |  |                     category()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! 'Ends with' predicate
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \overload | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename Range1T, typename Range2T> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline bool ends_with(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             const Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Test) | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::ends_with(Input, Test, is_equal()); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! 'Ends with' predicate ( case insensitive )
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							|  |  |  |             This predicate holds when the test container is a suffix of the Input. | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             In other words, if the input ends with the test. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             Elements are compared case insensitively. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             \param Input An input sequence | 
					
						
							|  |  |  |             \param Test A test sequence | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \param Loc A locale used for case insensitive comparison | 
					
						
							|  |  |  |             \return The result of the test | 
					
						
							| 
									
										
										
										
											2004-07-14 21:28:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-16 09:06:39 +00:00
										 |  |  |             \note This function provides the strong exception-safety guarantee | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename Range1T, typename Range2T> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline bool iends_with(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             const Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Test, | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             const std::locale& Loc=std::locale()) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::ends_with(Input, Test, is_iequal(Loc)); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //  contains predicate  -----------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! 'Contains' predicate
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							|  |  |  |             This predicate holds when the test container is contained in the Input. | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             When the optional predicate is specified, it is used for character-wise | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             comparison. | 
					
						
							| 
									
										
										
										
											2004-07-06 21:28:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             \param Input An input sequence | 
					
						
							|  |  |  |             \param Test A test sequence | 
					
						
							|  |  |  |             \param Comp An element comparison predicate | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \return The result of the test | 
					
						
							| 
									
										
										
										
											2004-07-14 21:28:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-16 09:06:39 +00:00
										 |  |  |                \note This function provides the strong exception-safety guarantee | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename Range1T, typename Range2T, typename PredicateT> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline bool contains(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             const Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Test, | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             PredicateT Comp) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input)); | 
					
						
							|  |  |  |             iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test)); | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             if (::boost::empty(lit_test)) | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             { | 
					
						
							|  |  |  |                 // Empty range is contained always
 | 
					
						
							|  |  |  |                 return true; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |              | 
					
						
							| 
									
										
										
										
											2004-08-02 10:32:37 +00:00
										 |  |  |             // Use the temporary variable to make VACPP happy
 | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             bool bResult=(::boost::algorithm::first_finder(lit_test,Comp)(::boost::begin(lit_input), ::boost::end(lit_input))); | 
					
						
							| 
									
										
										
										
											2004-08-02 10:32:37 +00:00
										 |  |  |             return bResult; | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! 'Contains' predicate
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \overload | 
					
						
							|  |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename Range1T, typename Range2T> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline bool contains(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             const Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Test) | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::contains(Input, Test, is_equal()); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! 'Contains' predicate ( case insensitive )
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							|  |  |  |             This predicate holds when the test container is contained in the Input. | 
					
						
							|  |  |  |             Elements are compared case insensitively. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             \param Input An input sequence | 
					
						
							|  |  |  |             \param Test A test sequence | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \param Loc A locale used for case insensitive comparison | 
					
						
							|  |  |  |             \return The result of the test | 
					
						
							| 
									
										
										
										
											2004-07-14 21:28:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-16 09:06:39 +00:00
										 |  |  |             \note This function provides the strong exception-safety guarantee | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename Range1T, typename Range2T> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline bool icontains(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             const Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Test,  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             const std::locale& Loc=std::locale()) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::contains(Input, Test, is_iequal(Loc)); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //  equals predicate  -----------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! 'Equals' predicate
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							|  |  |  |             This predicate holds when the test container is equal to the | 
					
						
							|  |  |  |             input container i.e. all elements in both containers are same. | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             When the optional predicate is specified, it is used for character-wise | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             comparison. | 
					
						
							| 
									
										
										
										
											2004-07-06 21:28:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             \param Input An input sequence | 
					
						
							|  |  |  |             \param Test A test sequence | 
					
						
							|  |  |  |             \param Comp An element comparison predicate | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \return The result of the test | 
					
						
							| 
									
										
										
										
											2004-07-06 21:28:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \note This is a two-way version of \c std::equal algorithm | 
					
						
							| 
									
										
										
										
											2004-07-14 21:28:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \note This function provides the strong exception-safety guarantee | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename Range1T, typename Range2T, typename PredicateT> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline bool equals(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             const Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Test, | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             PredicateT Comp) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input)); | 
					
						
							|  |  |  |             iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test)); | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             typedef BOOST_STRING_TYPENAME  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 range_const_iterator<Range1T>::type Iterator1T; | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             typedef BOOST_STRING_TYPENAME  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 range_const_iterator<Range2T>::type Iterator2T; | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |                  | 
					
						
							| 
									
										
										
										
											2008-06-17 21:04:00 +00:00
										 |  |  |             Iterator1T InputEnd=::boost::end(lit_input); | 
					
						
							|  |  |  |             Iterator2T TestEnd=::boost::end(lit_test); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-17 21:04:00 +00:00
										 |  |  |             Iterator1T it=::boost::begin(lit_input); | 
					
						
							|  |  |  |             Iterator2T pit=::boost::begin(lit_test); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             for(; | 
					
						
							|  |  |  |                 it!=InputEnd && pit!=TestEnd; | 
					
						
							|  |  |  |                 ++it,++pit) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 if( !(Comp(*it,*pit)) ) | 
					
						
							|  |  |  |                     return false; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             return  (pit==TestEnd) && (it==InputEnd); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! 'Equals' predicate
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \overload | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename Range1T, typename Range2T> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline bool equals(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             const Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Test) | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::equals(Input, Test, is_equal()); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-01-31 14:57:15 +00:00
										 |  |  |         //! 'Equals' predicate ( case insensitive )
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         /*!
 | 
					
						
							|  |  |  |             This predicate holds when the test container is equal to the | 
					
						
							|  |  |  |             input container i.e. all elements in both containers are same. | 
					
						
							|  |  |  |             Elements are compared case insensitively. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             \param Input An input sequence | 
					
						
							|  |  |  |             \param Test A test sequence | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \param Loc A locale used for case insensitive comparison | 
					
						
							|  |  |  |             \return The result of the test | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \note This is a two-way version of \c std::equal algorithm | 
					
						
							| 
									
										
										
										
											2004-07-14 21:28:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \note This function provides the strong exception-safety guarantee | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename Range1T, typename Range2T> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline bool iequals(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             const Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Test, | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             const std::locale& Loc=std::locale()) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::equals(Input, Test, is_iequal(Loc)); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-01-31 14:57:15 +00:00
										 |  |  | // lexicographical_compare predicate -----------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-06 18:10:18 +00:00
										 |  |  |         //! Lexicographical compare predicate
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							|  |  |  |              This predicate is an overload of std::lexicographical_compare | 
					
						
							|  |  |  |              for range arguments | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |              It check whether the first argument is lexicographically less | 
					
						
							|  |  |  |              then the second one. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |              If the optional predicate is specified, it is used for character-wise | 
					
						
							|  |  |  |              comparison | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |              \param Arg1 First argument  | 
					
						
							|  |  |  |              \param Arg2 Second argument | 
					
						
							|  |  |  |              \param Pred Comparison predicate | 
					
						
							|  |  |  |              \return The result of the test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |              \note This function provides the strong exception-safety guarantee | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         template<typename Range1T, typename Range2T, typename PredicateT> | 
					
						
							|  |  |  |         inline bool lexicographical_compare( | 
					
						
							|  |  |  |             const Range1T& Arg1, | 
					
						
							|  |  |  |             const Range2T& Arg2, | 
					
						
							|  |  |  |             PredicateT Pred) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_arg1(::boost::as_literal(Arg1)); | 
					
						
							|  |  |  |             iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_arg2(::boost::as_literal(Arg2)); | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-06 18:10:18 +00:00
										 |  |  |             return std::lexicographical_compare( | 
					
						
							| 
									
										
										
										
											2008-06-17 21:04:00 +00:00
										 |  |  |                 ::boost::begin(lit_arg1), | 
					
						
							|  |  |  |                 ::boost::end(lit_arg1), | 
					
						
							|  |  |  |                 ::boost::begin(lit_arg2), | 
					
						
							|  |  |  |                 ::boost::end(lit_arg2), | 
					
						
							| 
									
										
										
										
											2006-02-06 18:10:18 +00:00
										 |  |  |                 Pred); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! Lexicographical compare predicate
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							|  |  |  |             \overload | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         template<typename Range1T, typename Range2T> | 
					
						
							|  |  |  |             inline bool lexicographical_compare( | 
					
						
							|  |  |  |             const Range1T& Arg1, | 
					
						
							|  |  |  |             const Range2T& Arg2) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::lexicographical_compare(Arg1, Arg2, is_less()); | 
					
						
							| 
									
										
										
										
											2006-02-06 18:10:18 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! Lexicographical compare predicate (case-insensitive)
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							|  |  |  |             This predicate is an overload of std::lexicographical_compare | 
					
						
							|  |  |  |             for range arguments. | 
					
						
							|  |  |  |             It check whether the first argument is lexicographically less | 
					
						
							|  |  |  |             then the second one. | 
					
						
							|  |  |  |             Elements are compared case insensitively | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |              \param Arg1 First argument  | 
					
						
							|  |  |  |              \param Arg2 Second argument | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  |              \param Loc A locale used for case insensitive comparison | 
					
						
							| 
									
										
										
										
											2006-02-06 18:10:18 +00:00
										 |  |  |              \return The result of the test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |              \note This function provides the strong exception-safety guarantee | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         template<typename Range1T, typename Range2T> | 
					
						
							|  |  |  |         inline bool ilexicographical_compare( | 
					
						
							|  |  |  |             const Range1T& Arg1, | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  |             const Range2T& Arg2, | 
					
						
							|  |  |  |             const std::locale& Loc=std::locale()) | 
					
						
							| 
									
										
										
										
											2006-02-06 18:10:18 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::lexicographical_compare(Arg1, Arg2, is_iless(Loc)); | 
					
						
							| 
									
										
										
										
											2006-02-06 18:10:18 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |          | 
					
						
							| 
									
										
										
										
											2006-01-31 14:57:15 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | //  all predicate  -----------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! 'All' predicate
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							|  |  |  |             This predicate holds it all its elements satisfy a given  | 
					
						
							|  |  |  |             condition, represented by the predicate. | 
					
						
							|  |  |  |              | 
					
						
							|  |  |  |             \param Input An input sequence | 
					
						
							|  |  |  |             \param Pred A predicate | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \return The result of the test | 
					
						
							| 
									
										
										
										
											2004-07-14 21:28:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \note This function provides the strong exception-safety guarantee | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename RangeT, typename PredicateT> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline bool all(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             const RangeT& Input,  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             PredicateT Pred) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(::boost::as_literal(Input)); | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             typedef BOOST_STRING_TYPENAME  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 range_const_iterator<RangeT>::type Iterator1T; | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-17 21:04:00 +00:00
										 |  |  |             Iterator1T InputEnd=::boost::end(lit_input); | 
					
						
							|  |  |  |             for( Iterator1T It=::boost::begin(lit_input); It!=InputEnd; ++It) | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             { | 
					
						
							|  |  |  |                 if (!Pred(*It)) | 
					
						
							|  |  |  |                     return false; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |              | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } // namespace algorithm
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // pull names to the boost namespace
 | 
					
						
							|  |  |  |     using algorithm::starts_with; | 
					
						
							|  |  |  |     using algorithm::istarts_with; | 
					
						
							|  |  |  |     using algorithm::ends_with; | 
					
						
							|  |  |  |     using algorithm::iends_with; | 
					
						
							|  |  |  |     using algorithm::contains; | 
					
						
							|  |  |  |     using algorithm::icontains; | 
					
						
							|  |  |  |     using algorithm::equals; | 
					
						
							|  |  |  |     using algorithm::iequals; | 
					
						
							|  |  |  |     using algorithm::all; | 
					
						
							| 
									
										
										
										
											2006-02-06 18:10:18 +00:00
										 |  |  |     using algorithm::lexicographical_compare; | 
					
						
							|  |  |  |     using algorithm::ilexicographical_compare; | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // namespace boost
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif  // BOOST_STRING_PREDICATE_HPP
 |