| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | //  Boost string_algo library find.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_FIND_HPP
 | 
					
						
							|  |  |  | #define BOOST_STRING_FIND_HPP
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <boost/algorithm/string/config.hpp>
 | 
					
						
							| 
									
										
										
										
											2005-01-21 16:45:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-17 20:37:20 +00:00
										 |  |  | #include <boost/range/iterator_range_core.hpp>
 | 
					
						
							| 
									
										
										
										
											2005-01-21 16:45:29 +00:00
										 |  |  | #include <boost/range/begin.hpp>
 | 
					
						
							|  |  |  | #include <boost/range/end.hpp>
 | 
					
						
							|  |  |  | #include <boost/range/iterator.hpp>
 | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  | #include <boost/range/as_literal.hpp>
 | 
					
						
							| 
									
										
										
										
											2005-01-21 16:45:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | #include <boost/algorithm/string/finder.hpp>
 | 
					
						
							|  |  |  | #include <boost/algorithm/string/compare.hpp>
 | 
					
						
							|  |  |  | #include <boost/algorithm/string/constants.hpp>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*! \file
 | 
					
						
							|  |  |  |     Defines a set of find algorithms. The algorithms are searching | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |     for a substring of the input. The result is given as an \c iterator_range | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |     delimiting the substring. | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace boost { | 
					
						
							|  |  |  |     namespace algorithm { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //  Generic find -----------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! Generic find algorithm
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							|  |  |  |             Search the input using the given finder. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \param Input A string which will be searched. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             \param Finder Finder object used for searching. | 
					
						
							|  |  |  |             \return  | 
					
						
							|  |  |  |                 An \c iterator_range delimiting the match.  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 Returned iterator is either \c RangeT::iterator or  | 
					
						
							|  |  |  |                 \c RangeT::const_iterator, depending on the constness of  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |                 the input parameter. | 
					
						
							|  |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename RangeT, typename FinderT> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline iterator_range<  | 
					
						
							| 
									
										
										
										
											2007-10-27 22:52:29 +00:00
										 |  |  |             BOOST_STRING_TYPENAME range_iterator<RangeT>::type> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         find(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             RangeT& Input,  | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  |             const FinderT& Finder) | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_input(::boost::as_literal(Input)); | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-18 21:54:06 +00:00
										 |  |  |             return Finder(::boost::begin(lit_input),::boost::end(lit_input)); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //  find_first  -----------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! Find first algorithm
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  |             Search for the first occurrence of the substring in the input.  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |              | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \param Input A string which will be searched. | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \param Search A substring to be searched for. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             \return  | 
					
						
							|  |  |  |                 An \c iterator_range delimiting the match.  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 Returned iterator is either \c RangeT::iterator or  | 
					
						
							|  |  |  |                 \c RangeT::const_iterator, depending on the constness of  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |                 the input parameter. | 
					
						
							| 
									
										
										
										
											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 iterator_range<  | 
					
						
							| 
									
										
										
										
											2007-10-27 22:52:29 +00:00
										 |  |  |             BOOST_STRING_TYPENAME range_iterator<Range1T>::type> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         find_first(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Search) | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::find(Input, ::boost::algorithm::first_finder(Search)); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! Find first algorithm ( case insensitive )
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2012-12-28 17:51:56 +00:00
										 |  |  |             Search for the first occurrence of the substring in the input.  | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             Searching is case insensitive. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |              | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \param Input A string which will be searched. | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \param Search A substring to be searched for. | 
					
						
							|  |  |  |             \param Loc A locale used for case insensitive comparison | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             \return  | 
					
						
							|  |  |  |                 An \c iterator_range delimiting the match.  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 Returned iterator is either \c Range1T::iterator or  | 
					
						
							|  |  |  |                 \c Range1T::const_iterator, depending on the constness of  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |                 the input parameter. | 
					
						
							| 
									
										
										
										
											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 iterator_range<  | 
					
						
							| 
									
										
										
										
											2007-10-27 22:52:29 +00:00
										 |  |  |             BOOST_STRING_TYPENAME range_iterator<Range1T>::type> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         ifind_first(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Search, | 
					
						
							| 
									
										
										
										
											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::find(Input, ::boost::algorithm::first_finder(Search,is_iequal(Loc))); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //  find_last  -----------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! Find last algorithm
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  |             Search for the last occurrence of the substring in the input.  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |              | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \param Input A string which will be searched. | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \param Search A substring to be searched for. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             \return  | 
					
						
							|  |  |  |                 An \c iterator_range delimiting the match.  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 Returned iterator is either \c Range1T::iterator or  | 
					
						
							|  |  |  |                 \c Range1T::const_iterator, depending on the constness of  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |                 the input parameter. | 
					
						
							| 
									
										
										
										
											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 iterator_range<  | 
					
						
							| 
									
										
										
										
											2007-10-27 22:52:29 +00:00
										 |  |  |             BOOST_STRING_TYPENAME range_iterator<Range1T>::type> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         find_last(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Search) | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::find(Input, ::boost::algorithm::last_finder(Search)); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! Find last algorithm ( case insensitive )
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             Search for the last match a string in the input.  | 
					
						
							|  |  |  |             Searching is case insensitive. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |              | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \param Input A string which will be searched. | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \param Search A substring to be searched for. | 
					
						
							|  |  |  |             \param Loc A locale used for case insensitive comparison | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             \return  | 
					
						
							|  |  |  |                 An \c iterator_range delimiting the match.  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 Returned iterator is either \c Range1T::iterator or  | 
					
						
							|  |  |  |                 \c Range1T::const_iterator, depending on the constness of  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |                 the input parameter. | 
					
						
							| 
									
										
										
										
											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> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline iterator_range<  | 
					
						
							| 
									
										
										
										
											2007-10-27 22:52:29 +00:00
										 |  |  |             BOOST_STRING_TYPENAME range_iterator<Range1T>::type> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         ifind_last(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Search, | 
					
						
							| 
									
										
										
										
											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::find(Input, ::boost::algorithm::last_finder(Search, is_iequal(Loc))); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //  find_nth ----------------------------------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! Find n-th algorithm 
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2007-07-01 22:23:55 +00:00
										 |  |  |             Search for the n-th (zero-indexed) occurrence of the substring in the  | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             input.          | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |              | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \param Input A string which will be searched. | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \param Search A substring to be searched for. | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \param Nth An index (zero-indexed) of the match to be found. | 
					
						
							| 
									
										
										
										
											2006-03-07 13:09:36 +00:00
										 |  |  |                 For negative N, the matches are counted from the end of string. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             \return  | 
					
						
							|  |  |  |                 An \c iterator_range delimiting the match.  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 Returned iterator is either \c Range1T::iterator or  | 
					
						
							|  |  |  |                 \c Range1T::const_iterator, depending on the constness of  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |                 the input parameter. | 
					
						
							|  |  |  |         */ | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |         template<typename Range1T, typename Range2T> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline iterator_range<  | 
					
						
							| 
									
										
										
										
											2007-10-27 22:52:29 +00:00
										 |  |  |             BOOST_STRING_TYPENAME range_iterator<Range1T>::type> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         find_nth(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Search, | 
					
						
							| 
									
										
										
										
											2006-01-31 12:36:32 +00:00
										 |  |  |             int Nth) | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::find(Input, ::boost::algorithm::nth_finder(Search,Nth)); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! Find n-th algorithm ( case insensitive ).
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2006-03-07 13:09:36 +00:00
										 |  |  |             Search for the n-th (zero-indexed) occurrence of the substring in the  | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             input. Searching is case insensitive. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |              | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \param Input A string which will be searched. | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \param Search A substring to be searched for. | 
					
						
							| 
									
										
										
										
											2006-03-07 13:09:36 +00:00
										 |  |  |             \param Nth An index (zero-indexed) of the match to be found.  | 
					
						
							|  |  |  |                 For negative N, the matches are counted from the end of string. | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \param Loc A locale used for case insensitive comparison | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             \return  | 
					
						
							|  |  |  |                 An \c iterator_range delimiting the match.  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 Returned iterator is either \c Range1T::iterator or  | 
					
						
							|  |  |  |                 \c Range1T::const_iterator, depending on the constness of  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |                 the input parameter. | 
					
						
							| 
									
										
										
										
											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 iterator_range<  | 
					
						
							| 
									
										
										
										
											2007-10-27 22:52:29 +00:00
										 |  |  |             BOOST_STRING_TYPENAME range_iterator<Range1T>::type> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         ifind_nth(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             Range1T& Input,  | 
					
						
							|  |  |  |             const Range2T& Search, | 
					
						
							| 
									
										
										
										
											2006-01-31 12:36:32 +00:00
										 |  |  |             int Nth, | 
					
						
							| 
									
										
										
										
											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::find(Input, ::boost::algorithm::nth_finder(Search,Nth,is_iequal(Loc))); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //  find_head ----------------------------------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! Find head algorithm
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             Get the head of the input. Head is a prefix of the string of the  | 
					
						
							| 
									
										
										
										
											2012-02-23 19:36:45 +00:00
										 |  |  |             given size. If the input is shorter then required, whole input is considered  | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             to be the head. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \param Input An input string | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             \param N Length of the head | 
					
						
							| 
									
										
										
										
											2006-03-07 13:09:36 +00:00
										 |  |  |                 For N>=0, at most N characters are extracted. | 
					
						
							| 
									
										
										
										
											2012-02-27 20:40:58 +00:00
										 |  |  |                 For N<0, at most size(Input)-|N| characters are extracted. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             \return  | 
					
						
							|  |  |  |                 An \c iterator_range delimiting the match.  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 Returned iterator is either \c Range1T::iterator or  | 
					
						
							|  |  |  |                 \c Range1T::const_iterator, depending on the constness of  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |                 the input parameter. | 
					
						
							| 
									
										
										
										
											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 RangeT> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline iterator_range<  | 
					
						
							| 
									
										
										
										
											2007-10-27 22:52:29 +00:00
										 |  |  |             BOOST_STRING_TYPENAME range_iterator<RangeT>::type> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         find_head(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             RangeT& Input,  | 
					
						
							| 
									
										
										
										
											2006-01-31 12:36:32 +00:00
										 |  |  |             int N) | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::find(Input, ::boost::algorithm::head_finder(N)); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //  find_tail ----------------------------------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! Find tail algorithm
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2010-06-09 20:26:36 +00:00
										 |  |  |             Get the tail of the input. Tail is a suffix of the string of the  | 
					
						
							| 
									
										
										
										
											2012-02-23 19:36:45 +00:00
										 |  |  |             given size. If the input is shorter then required, whole input is considered  | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             to be the tail. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \param Input An input string | 
					
						
							| 
									
										
										
										
											2006-03-07 13:09:36 +00:00
										 |  |  |             \param N Length of the tail.  | 
					
						
							|  |  |  |                 For N>=0, at most N characters are extracted. | 
					
						
							| 
									
										
										
										
											2012-02-27 20:40:58 +00:00
										 |  |  |                 For N<0, at most size(Input)-|N| characters are extracted. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             \return  | 
					
						
							|  |  |  |                 An \c iterator_range delimiting the match.  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 Returned iterator is either \c RangeT::iterator or  | 
					
						
							|  |  |  |                 \c RangeT::const_iterator, depending on the constness of  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |                 the input parameter. | 
					
						
							| 
									
										
										
										
											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 RangeT> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline iterator_range<  | 
					
						
							| 
									
										
										
										
											2007-10-27 22:52:29 +00:00
										 |  |  |             BOOST_STRING_TYPENAME range_iterator<RangeT>::type> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         find_tail(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             RangeT& Input,  | 
					
						
							| 
									
										
										
										
											2006-01-31 12:36:32 +00:00
										 |  |  |             int N) | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::find(Input, ::boost::algorithm::tail_finder(N)); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //  find_token --------------------------------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! Find token algorithm
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             Look for a given token in the string. Token is a character that matches the | 
					
						
							|  |  |  |             given predicate. | 
					
						
							|  |  |  |             If the "token compress mode" is enabled, adjacent tokens are considered to be one match. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |              | 
					
						
							| 
									
										
										
										
											2004-07-11 22:07:00 +00:00
										 |  |  |             \param Input A input string. | 
					
						
							| 
									
										
										
										
											2012-12-28 17:51:56 +00:00
										 |  |  |             \param Pred A unary predicate to identify a token | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             \param eCompress Enable/Disable compressing of adjacent tokens | 
					
						
							|  |  |  |             \return  | 
					
						
							|  |  |  |                 An \c iterator_range delimiting the match.  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |                 Returned iterator is either \c RangeT::iterator or  | 
					
						
							|  |  |  |                 \c RangeT::const_iterator, depending on the constness of  | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |                 the input parameter. | 
					
						
							| 
									
										
										
										
											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 RangeT, typename PredicateT> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         inline iterator_range<  | 
					
						
							| 
									
										
										
										
											2007-10-27 22:52:29 +00:00
										 |  |  |             BOOST_STRING_TYPENAME range_iterator<RangeT>::type> | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         find_token(  | 
					
						
							| 
									
										
										
										
											2005-04-12 16:50:42 +00:00
										 |  |  |             RangeT& Input, | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             PredicateT Pred, | 
					
						
							|  |  |  |             token_compress_mode_type eCompress=token_compress_off) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2009-08-05 20:01:10 +00:00
										 |  |  |             return ::boost::algorithm::find(Input, ::boost::algorithm::token_finder(Pred, eCompress)); | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } // namespace algorithm
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // pull names to the boost namespace
 | 
					
						
							|  |  |  |     using algorithm::find; | 
					
						
							|  |  |  |     using algorithm::find_first; | 
					
						
							|  |  |  |     using algorithm::ifind_first; | 
					
						
							|  |  |  |     using algorithm::find_last; | 
					
						
							|  |  |  |     using algorithm::ifind_last; | 
					
						
							|  |  |  |     using algorithm::find_nth; | 
					
						
							|  |  |  |     using algorithm::ifind_nth; | 
					
						
							|  |  |  |     using algorithm::find_head; | 
					
						
							|  |  |  |     using algorithm::find_tail; | 
					
						
							|  |  |  |     using algorithm::find_token; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace boost
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif  // BOOST_STRING_FIND_HPP
 |