annotate DEPENDENCIES/generic/include/boost/algorithm/string/finder.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Boost string_algo library finder.hpp header file ---------------------------//
Chris@16 2
Chris@16 3 // Copyright Pavol Droba 2002-2006.
Chris@16 4 //
Chris@16 5 // Distributed under the Boost Software License, Version 1.0.
Chris@16 6 // (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8
Chris@16 9 // See http://www.boost.org/ for updates, documentation, and revision history.
Chris@16 10
Chris@16 11 #ifndef BOOST_STRING_FINDER_HPP
Chris@16 12 #define BOOST_STRING_FINDER_HPP
Chris@16 13
Chris@16 14 #include <boost/algorithm/string/config.hpp>
Chris@16 15
Chris@16 16 #include <boost/range/iterator_range_core.hpp>
Chris@16 17 #include <boost/range/begin.hpp>
Chris@16 18 #include <boost/range/end.hpp>
Chris@16 19 #include <boost/range/iterator.hpp>
Chris@16 20 #include <boost/range/const_iterator.hpp>
Chris@16 21
Chris@16 22 #include <boost/algorithm/string/constants.hpp>
Chris@16 23 #include <boost/algorithm/string/detail/finder.hpp>
Chris@16 24 #include <boost/algorithm/string/compare.hpp>
Chris@16 25
Chris@16 26 /*! \file
Chris@16 27 Defines Finder generators. Finder object is a functor which is able to
Chris@16 28 find a substring matching a specific criteria in the input.
Chris@16 29 Finders are used as a pluggable components for replace, find
Chris@16 30 and split facilities. This header contains generator functions
Chris@16 31 for finders provided in this library.
Chris@16 32 */
Chris@16 33
Chris@16 34 namespace boost {
Chris@16 35 namespace algorithm {
Chris@16 36
Chris@16 37 // Finder generators ------------------------------------------//
Chris@16 38
Chris@16 39 //! "First" finder
Chris@16 40 /*!
Chris@16 41 Construct the \c first_finder. The finder searches for the first
Chris@16 42 occurrence of the string in a given input.
Chris@16 43 The result is given as an \c iterator_range delimiting the match.
Chris@16 44
Chris@16 45 \param Search A substring to be searched for.
Chris@16 46 \param Comp An element comparison predicate
Chris@16 47 \return An instance of the \c first_finder object
Chris@16 48 */
Chris@16 49 template<typename RangeT>
Chris@16 50 inline detail::first_finderF<
Chris@16 51 BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
Chris@16 52 is_equal>
Chris@16 53 first_finder( const RangeT& Search )
Chris@16 54 {
Chris@16 55 return
Chris@16 56 detail::first_finderF<
Chris@16 57 BOOST_STRING_TYPENAME
Chris@16 58 range_const_iterator<RangeT>::type,
Chris@16 59 is_equal>( ::boost::as_literal(Search), is_equal() ) ;
Chris@16 60 }
Chris@16 61
Chris@16 62 //! "First" finder
Chris@16 63 /*!
Chris@16 64 \overload
Chris@16 65 */
Chris@16 66 template<typename RangeT,typename PredicateT>
Chris@16 67 inline detail::first_finderF<
Chris@16 68 BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
Chris@16 69 PredicateT>
Chris@16 70 first_finder(
Chris@16 71 const RangeT& Search, PredicateT Comp )
Chris@16 72 {
Chris@16 73 return
Chris@16 74 detail::first_finderF<
Chris@16 75 BOOST_STRING_TYPENAME
Chris@16 76 range_const_iterator<RangeT>::type,
Chris@16 77 PredicateT>( ::boost::as_literal(Search), Comp );
Chris@16 78 }
Chris@16 79
Chris@16 80 //! "Last" finder
Chris@16 81 /*!
Chris@16 82 Construct the \c last_finder. The finder searches for the last
Chris@16 83 occurrence of the string in a given input.
Chris@16 84 The result is given as an \c iterator_range delimiting the match.
Chris@16 85
Chris@16 86 \param Search A substring to be searched for.
Chris@16 87 \param Comp An element comparison predicate
Chris@16 88 \return An instance of the \c last_finder object
Chris@16 89 */
Chris@16 90 template<typename RangeT>
Chris@16 91 inline detail::last_finderF<
Chris@16 92 BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
Chris@16 93 is_equal>
Chris@16 94 last_finder( const RangeT& Search )
Chris@16 95 {
Chris@16 96 return
Chris@16 97 detail::last_finderF<
Chris@16 98 BOOST_STRING_TYPENAME
Chris@16 99 range_const_iterator<RangeT>::type,
Chris@16 100 is_equal>( ::boost::as_literal(Search), is_equal() );
Chris@16 101 }
Chris@16 102 //! "Last" finder
Chris@16 103 /*!
Chris@16 104 \overload
Chris@16 105 */
Chris@16 106 template<typename RangeT, typename PredicateT>
Chris@16 107 inline detail::last_finderF<
Chris@16 108 BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
Chris@16 109 PredicateT>
Chris@16 110 last_finder( const RangeT& Search, PredicateT Comp )
Chris@16 111 {
Chris@16 112 return
Chris@16 113 detail::last_finderF<
Chris@16 114 BOOST_STRING_TYPENAME
Chris@16 115 range_const_iterator<RangeT>::type,
Chris@16 116 PredicateT>( ::boost::as_literal(Search), Comp ) ;
Chris@16 117 }
Chris@16 118
Chris@16 119 //! "Nth" finder
Chris@16 120 /*!
Chris@16 121 Construct the \c nth_finder. The finder searches for the n-th (zero-indexed)
Chris@16 122 occurrence of the string in a given input.
Chris@16 123 The result is given as an \c iterator_range delimiting the match.
Chris@16 124
Chris@16 125 \param Search A substring to be searched for.
Chris@16 126 \param Nth An index of the match to be find
Chris@16 127 \param Comp An element comparison predicate
Chris@16 128 \return An instance of the \c nth_finder object
Chris@16 129 */
Chris@16 130 template<typename RangeT>
Chris@16 131 inline detail::nth_finderF<
Chris@16 132 BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
Chris@16 133 is_equal>
Chris@16 134 nth_finder(
Chris@16 135 const RangeT& Search,
Chris@16 136 int Nth)
Chris@16 137 {
Chris@16 138 return
Chris@16 139 detail::nth_finderF<
Chris@16 140 BOOST_STRING_TYPENAME
Chris@16 141 range_const_iterator<RangeT>::type,
Chris@16 142 is_equal>( ::boost::as_literal(Search), Nth, is_equal() ) ;
Chris@16 143 }
Chris@16 144 //! "Nth" finder
Chris@16 145 /*!
Chris@16 146 \overload
Chris@16 147 */
Chris@16 148 template<typename RangeT, typename PredicateT>
Chris@16 149 inline detail::nth_finderF<
Chris@16 150 BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
Chris@16 151 PredicateT>
Chris@16 152 nth_finder(
Chris@16 153 const RangeT& Search,
Chris@16 154 int Nth,
Chris@16 155 PredicateT Comp )
Chris@16 156 {
Chris@16 157 return
Chris@16 158 detail::nth_finderF<
Chris@16 159 BOOST_STRING_TYPENAME
Chris@16 160 range_const_iterator<RangeT>::type,
Chris@16 161 PredicateT>( ::boost::as_literal(Search), Nth, Comp );
Chris@16 162 }
Chris@16 163
Chris@16 164 //! "Head" finder
Chris@16 165 /*!
Chris@16 166 Construct the \c head_finder. The finder returns a head of a given
Chris@16 167 input. The head is a prefix of a string up to n elements in
Chris@16 168 size. If an input has less then n elements, whole input is
Chris@16 169 considered a head.
Chris@16 170 The result is given as an \c iterator_range delimiting the match.
Chris@16 171
Chris@16 172 \param N The size of the head
Chris@16 173 \return An instance of the \c head_finder object
Chris@16 174 */
Chris@16 175 inline detail::head_finderF
Chris@16 176 head_finder( int N )
Chris@16 177 {
Chris@16 178 return detail::head_finderF(N);
Chris@16 179 }
Chris@16 180
Chris@16 181 //! "Tail" finder
Chris@16 182 /*!
Chris@16 183 Construct the \c tail_finder. The finder returns a tail of a given
Chris@16 184 input. The tail is a suffix of a string up to n elements in
Chris@16 185 size. If an input has less then n elements, whole input is
Chris@16 186 considered a head.
Chris@16 187 The result is given as an \c iterator_range delimiting the match.
Chris@16 188
Chris@16 189 \param N The size of the head
Chris@16 190 \return An instance of the \c tail_finder object
Chris@16 191 */
Chris@16 192 inline detail::tail_finderF
Chris@16 193 tail_finder( int N )
Chris@16 194 {
Chris@16 195 return detail::tail_finderF(N);
Chris@16 196 }
Chris@16 197
Chris@16 198 //! "Token" finder
Chris@16 199 /*!
Chris@16 200 Construct the \c token_finder. The finder searches for a token
Chris@16 201 specified by a predicate. It is similar to std::find_if
Chris@16 202 algorithm, with an exception that it return a range of
Chris@16 203 instead of a single iterator.
Chris@16 204
Chris@16 205 If "compress token mode" is enabled, adjacent matching tokens are
Chris@16 206 concatenated into one match. Thus the finder can be used to
Chris@16 207 search for continuous segments of characters satisfying the
Chris@16 208 given predicate.
Chris@16 209
Chris@16 210 The result is given as an \c iterator_range delimiting the match.
Chris@16 211
Chris@16 212 \param Pred An element selection predicate
Chris@16 213 \param eCompress Compress flag
Chris@16 214 \return An instance of the \c token_finder object
Chris@16 215 */
Chris@16 216 template< typename PredicateT >
Chris@16 217 inline detail::token_finderF<PredicateT>
Chris@16 218 token_finder(
Chris@16 219 PredicateT Pred,
Chris@16 220 token_compress_mode_type eCompress=token_compress_off )
Chris@16 221 {
Chris@16 222 return detail::token_finderF<PredicateT>( Pred, eCompress );
Chris@16 223 }
Chris@16 224
Chris@16 225 //! "Range" finder
Chris@16 226 /*!
Chris@16 227 Construct the \c range_finder. The finder does not perform
Chris@16 228 any operation. It simply returns the given range for
Chris@16 229 any input.
Chris@16 230
Chris@16 231 \param Begin Beginning of the range
Chris@16 232 \param End End of the range
Chris@16 233 \param Range The range.
Chris@16 234 \return An instance of the \c range_finger object
Chris@16 235 */
Chris@16 236 template< typename ForwardIteratorT >
Chris@16 237 inline detail::range_finderF<ForwardIteratorT>
Chris@16 238 range_finder(
Chris@16 239 ForwardIteratorT Begin,
Chris@16 240 ForwardIteratorT End )
Chris@16 241 {
Chris@16 242 return detail::range_finderF<ForwardIteratorT>( Begin, End );
Chris@16 243 }
Chris@16 244
Chris@16 245 //! "Range" finder
Chris@16 246 /*!
Chris@16 247 \overload
Chris@16 248 */
Chris@16 249 template< typename ForwardIteratorT >
Chris@16 250 inline detail::range_finderF<ForwardIteratorT>
Chris@16 251 range_finder( iterator_range<ForwardIteratorT> Range )
Chris@16 252 {
Chris@16 253 return detail::range_finderF<ForwardIteratorT>( Range );
Chris@16 254 }
Chris@16 255
Chris@16 256 } // namespace algorithm
Chris@16 257
Chris@16 258 // pull the names to the boost namespace
Chris@16 259 using algorithm::first_finder;
Chris@16 260 using algorithm::last_finder;
Chris@16 261 using algorithm::nth_finder;
Chris@16 262 using algorithm::head_finder;
Chris@16 263 using algorithm::tail_finder;
Chris@16 264 using algorithm::token_finder;
Chris@16 265 using algorithm::range_finder;
Chris@16 266
Chris@16 267 } // namespace boost
Chris@16 268
Chris@16 269
Chris@16 270 #endif // BOOST_STRING_FINDER_HPP