Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / algorithm / string / finder.hpp @ 2486

History | View | Annotate | Download (9.4 kB)

1 2486 sjacqu01
//  Boost string_algo library finder.hpp header file  ---------------------------//
2 2486 sjacqu01
3 2486 sjacqu01
//  Copyright Pavol Droba 2002-2006.
4 2486 sjacqu01
//
5 2486 sjacqu01
// Distributed under the Boost Software License, Version 1.0.
6 2486 sjacqu01
//    (See accompanying file LICENSE_1_0.txt or copy at
7 2486 sjacqu01
//          http://www.boost.org/LICENSE_1_0.txt)
8 2486 sjacqu01
9 2486 sjacqu01
//  See http://www.boost.org/ for updates, documentation, and revision history.
10 2486 sjacqu01
11 2486 sjacqu01
#ifndef BOOST_STRING_FINDER_HPP
12 2486 sjacqu01
#define BOOST_STRING_FINDER_HPP
13 2486 sjacqu01
14 2486 sjacqu01
#include <boost/algorithm/string/config.hpp>
15 2486 sjacqu01
16 2486 sjacqu01
#include <boost/range/iterator_range_core.hpp>
17 2486 sjacqu01
#include <boost/range/begin.hpp>
18 2486 sjacqu01
#include <boost/range/end.hpp>
19 2486 sjacqu01
#include <boost/range/iterator.hpp>
20 2486 sjacqu01
#include <boost/range/const_iterator.hpp>
21 2486 sjacqu01
22 2486 sjacqu01
#include <boost/algorithm/string/constants.hpp>
23 2486 sjacqu01
#include <boost/algorithm/string/detail/finder.hpp>
24 2486 sjacqu01
#include <boost/algorithm/string/compare.hpp>
25 2486 sjacqu01
26 2486 sjacqu01
/*! \file
27 2486 sjacqu01
    Defines Finder generators. Finder object is a functor which is able to
28 2486 sjacqu01
    find a substring matching a specific criteria in the input.
29 2486 sjacqu01
    Finders are used as a pluggable components for replace, find
30 2486 sjacqu01
    and split facilities. This header contains generator functions
31 2486 sjacqu01
    for finders provided in this library.
32 2486 sjacqu01
*/
33 2486 sjacqu01
34 2486 sjacqu01
namespace boost {
35 2486 sjacqu01
    namespace algorithm {
36 2486 sjacqu01
37 2486 sjacqu01
//  Finder generators ------------------------------------------//
38 2486 sjacqu01
39 2486 sjacqu01
        //! "First" finder
40 2486 sjacqu01
        /*!
41 2486 sjacqu01
            Construct the \c first_finder. The finder searches for the first
42 2486 sjacqu01
            occurrence of the string in a given input.
43 2486 sjacqu01
            The result is given as an \c iterator_range delimiting the match.
44 2486 sjacqu01

45 2486 sjacqu01
            \param Search A substring to be searched for.
46 2486 sjacqu01
            \param Comp An element comparison predicate
47 2486 sjacqu01
            \return An instance of the \c first_finder object
48 2486 sjacqu01
        */
49 2486 sjacqu01
        template<typename RangeT>
50 2486 sjacqu01
        inline detail::first_finderF<
51 2486 sjacqu01
            BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
52 2486 sjacqu01
            is_equal>
53 2486 sjacqu01
        first_finder( const RangeT& Search )
54 2486 sjacqu01
        {
55 2486 sjacqu01
            return
56 2486 sjacqu01
                detail::first_finderF<
57 2486 sjacqu01
                    BOOST_STRING_TYPENAME
58 2486 sjacqu01
                        range_const_iterator<RangeT>::type,
59 2486 sjacqu01
                        is_equal>( ::boost::as_literal(Search), is_equal() ) ;
60 2486 sjacqu01
        }
61 2486 sjacqu01
62 2486 sjacqu01
        //! "First" finder
63 2486 sjacqu01
        /*!
64 2486 sjacqu01
            \overload
65 2486 sjacqu01
        */
66 2486 sjacqu01
        template<typename RangeT,typename PredicateT>
67 2486 sjacqu01
        inline detail::first_finderF<
68 2486 sjacqu01
            BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
69 2486 sjacqu01
            PredicateT>
70 2486 sjacqu01
        first_finder(
71 2486 sjacqu01
            const RangeT& Search, PredicateT Comp )
72 2486 sjacqu01
        {
73 2486 sjacqu01
            return
74 2486 sjacqu01
                detail::first_finderF<
75 2486 sjacqu01
                    BOOST_STRING_TYPENAME
76 2486 sjacqu01
                        range_const_iterator<RangeT>::type,
77 2486 sjacqu01
                    PredicateT>( ::boost::as_literal(Search), Comp );
78 2486 sjacqu01
        }
79 2486 sjacqu01
80 2486 sjacqu01
        //! "Last" finder
81 2486 sjacqu01
        /*!
82 2486 sjacqu01
            Construct the \c last_finder. The finder searches for the last
83 2486 sjacqu01
            occurrence of the string in a given input.
84 2486 sjacqu01
            The result is given as an \c iterator_range delimiting the match.
85 2486 sjacqu01

86 2486 sjacqu01
            \param Search A substring to be searched for.
87 2486 sjacqu01
            \param Comp An element comparison predicate
88 2486 sjacqu01
            \return An instance of the \c last_finder object
89 2486 sjacqu01
        */
90 2486 sjacqu01
        template<typename RangeT>
91 2486 sjacqu01
        inline detail::last_finderF<
92 2486 sjacqu01
            BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
93 2486 sjacqu01
            is_equal>
94 2486 sjacqu01
        last_finder( const RangeT& Search )
95 2486 sjacqu01
        {
96 2486 sjacqu01
            return
97 2486 sjacqu01
                detail::last_finderF<
98 2486 sjacqu01
                    BOOST_STRING_TYPENAME
99 2486 sjacqu01
                        range_const_iterator<RangeT>::type,
100 2486 sjacqu01
                    is_equal>( ::boost::as_literal(Search), is_equal() );
101 2486 sjacqu01
        }
102 2486 sjacqu01
        //! "Last" finder
103 2486 sjacqu01
        /*!
104 2486 sjacqu01
            \overload
105 2486 sjacqu01
        */
106 2486 sjacqu01
        template<typename RangeT, typename PredicateT>
107 2486 sjacqu01
        inline detail::last_finderF<
108 2486 sjacqu01
            BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
109 2486 sjacqu01
            PredicateT>
110 2486 sjacqu01
        last_finder( const RangeT& Search, PredicateT Comp )
111 2486 sjacqu01
        {
112 2486 sjacqu01
            return
113 2486 sjacqu01
                detail::last_finderF<
114 2486 sjacqu01
                    BOOST_STRING_TYPENAME
115 2486 sjacqu01
                        range_const_iterator<RangeT>::type,
116 2486 sjacqu01
                    PredicateT>( ::boost::as_literal(Search), Comp ) ;
117 2486 sjacqu01
        }
118 2486 sjacqu01
119 2486 sjacqu01
        //! "Nth" finder
120 2486 sjacqu01
        /*!
121 2486 sjacqu01
            Construct the \c nth_finder. The finder searches for the n-th (zero-indexed)
122 2486 sjacqu01
            occurrence of the string in a given input.
123 2486 sjacqu01
            The result is given as an \c iterator_range delimiting the match.
124 2486 sjacqu01

125 2486 sjacqu01
            \param Search A substring to be searched for.
126 2486 sjacqu01
            \param Nth An index of the match to be find
127 2486 sjacqu01
            \param Comp An element comparison predicate
128 2486 sjacqu01
            \return An instance of the \c nth_finder object
129 2486 sjacqu01
        */
130 2486 sjacqu01
        template<typename RangeT>
131 2486 sjacqu01
        inline detail::nth_finderF<
132 2486 sjacqu01
            BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
133 2486 sjacqu01
            is_equal>
134 2486 sjacqu01
        nth_finder(
135 2486 sjacqu01
            const RangeT& Search,
136 2486 sjacqu01
            int Nth)
137 2486 sjacqu01
        {
138 2486 sjacqu01
            return
139 2486 sjacqu01
                detail::nth_finderF<
140 2486 sjacqu01
                    BOOST_STRING_TYPENAME
141 2486 sjacqu01
                        range_const_iterator<RangeT>::type,
142 2486 sjacqu01
                    is_equal>( ::boost::as_literal(Search), Nth, is_equal() ) ;
143 2486 sjacqu01
        }
144 2486 sjacqu01
        //! "Nth" finder
145 2486 sjacqu01
        /*!
146 2486 sjacqu01
            \overload
147 2486 sjacqu01
        */
148 2486 sjacqu01
        template<typename RangeT, typename PredicateT>
149 2486 sjacqu01
        inline detail::nth_finderF<
150 2486 sjacqu01
            BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
151 2486 sjacqu01
            PredicateT>
152 2486 sjacqu01
        nth_finder(
153 2486 sjacqu01
            const RangeT& Search,
154 2486 sjacqu01
            int Nth,
155 2486 sjacqu01
            PredicateT Comp )
156 2486 sjacqu01
        {
157 2486 sjacqu01
            return
158 2486 sjacqu01
                detail::nth_finderF<
159 2486 sjacqu01
                    BOOST_STRING_TYPENAME
160 2486 sjacqu01
                        range_const_iterator<RangeT>::type,
161 2486 sjacqu01
                    PredicateT>( ::boost::as_literal(Search), Nth, Comp );
162 2486 sjacqu01
        }
163 2486 sjacqu01
164 2486 sjacqu01
        //! "Head" finder
165 2486 sjacqu01
        /*!
166 2486 sjacqu01
            Construct the \c head_finder. The finder returns a head of a given
167 2486 sjacqu01
            input. The head is a prefix of a string up to n elements in
168 2486 sjacqu01
            size. If an input has less then n elements, whole input is
169 2486 sjacqu01
            considered a head.
170 2486 sjacqu01
            The result is given as an \c iterator_range delimiting the match.
171 2486 sjacqu01

172 2486 sjacqu01
            \param N The size of the head
173 2486 sjacqu01
            \return An instance of the \c head_finder object
174 2486 sjacqu01
        */
175 2486 sjacqu01
        inline detail::head_finderF
176 2486 sjacqu01
        head_finder( int N )
177 2486 sjacqu01
        {
178 2486 sjacqu01
            return detail::head_finderF(N);
179 2486 sjacqu01
        }
180 2486 sjacqu01
181 2486 sjacqu01
        //! "Tail" finder
182 2486 sjacqu01
        /*!
183 2486 sjacqu01
            Construct the \c tail_finder. The finder returns a tail of a given
184 2486 sjacqu01
            input. The tail is a suffix of a string up to n elements in
185 2486 sjacqu01
            size. If an input has less then n elements, whole input is
186 2486 sjacqu01
            considered a head.
187 2486 sjacqu01
            The result is given as an \c iterator_range delimiting the match.
188 2486 sjacqu01

189 2486 sjacqu01
            \param N The size of the head
190 2486 sjacqu01
            \return An instance of the \c tail_finder object
191 2486 sjacqu01
        */
192 2486 sjacqu01
        inline detail::tail_finderF
193 2486 sjacqu01
        tail_finder( int N )
194 2486 sjacqu01
        {
195 2486 sjacqu01
            return detail::tail_finderF(N);
196 2486 sjacqu01
        }
197 2486 sjacqu01
198 2486 sjacqu01
        //! "Token" finder
199 2486 sjacqu01
        /*!
200 2486 sjacqu01
            Construct the \c token_finder. The finder searches for a token
201 2486 sjacqu01
            specified by a predicate. It is similar to std::find_if
202 2486 sjacqu01
            algorithm, with an exception that it return a range of
203 2486 sjacqu01
            instead of a single iterator.
204 2486 sjacqu01

205 2486 sjacqu01
            If "compress token mode" is enabled, adjacent matching tokens are
206 2486 sjacqu01
            concatenated into one match. Thus the finder can be used to
207 2486 sjacqu01
            search for continuous segments of characters satisfying the
208 2486 sjacqu01
            given predicate.
209 2486 sjacqu01

210 2486 sjacqu01
            The result is given as an \c iterator_range delimiting the match.
211 2486 sjacqu01

212 2486 sjacqu01
            \param Pred An element selection predicate
213 2486 sjacqu01
            \param eCompress Compress flag
214 2486 sjacqu01
            \return An instance of the \c token_finder object
215 2486 sjacqu01
        */
216 2486 sjacqu01
        template< typename PredicateT >
217 2486 sjacqu01
        inline detail::token_finderF<PredicateT>
218 2486 sjacqu01
        token_finder(
219 2486 sjacqu01
            PredicateT Pred,
220 2486 sjacqu01
            token_compress_mode_type eCompress=token_compress_off )
221 2486 sjacqu01
        {
222 2486 sjacqu01
            return detail::token_finderF<PredicateT>( Pred, eCompress );
223 2486 sjacqu01
        }
224 2486 sjacqu01
225 2486 sjacqu01
        //! "Range" finder
226 2486 sjacqu01
        /*!
227 2486 sjacqu01
            Construct the \c range_finder. The finder does not perform
228 2486 sjacqu01
            any operation. It simply returns the given range for
229 2486 sjacqu01
            any input.
230 2486 sjacqu01

231 2486 sjacqu01
            \param Begin Beginning of the range
232 2486 sjacqu01
            \param End End of the range
233 2486 sjacqu01
            \param Range The range.
234 2486 sjacqu01
            \return An instance of the \c range_finger object
235 2486 sjacqu01
        */
236 2486 sjacqu01
        template< typename ForwardIteratorT >
237 2486 sjacqu01
        inline detail::range_finderF<ForwardIteratorT>
238 2486 sjacqu01
        range_finder(
239 2486 sjacqu01
            ForwardIteratorT Begin,
240 2486 sjacqu01
            ForwardIteratorT End )
241 2486 sjacqu01
        {
242 2486 sjacqu01
            return detail::range_finderF<ForwardIteratorT>( Begin, End );
243 2486 sjacqu01
        }
244 2486 sjacqu01
245 2486 sjacqu01
        //! "Range" finder
246 2486 sjacqu01
        /*!
247 2486 sjacqu01
            \overload
248 2486 sjacqu01
        */
249 2486 sjacqu01
        template< typename ForwardIteratorT >
250 2486 sjacqu01
        inline detail::range_finderF<ForwardIteratorT>
251 2486 sjacqu01
        range_finder( iterator_range<ForwardIteratorT> Range )
252 2486 sjacqu01
        {
253 2486 sjacqu01
            return detail::range_finderF<ForwardIteratorT>( Range );
254 2486 sjacqu01
        }
255 2486 sjacqu01
256 2486 sjacqu01
    } // namespace algorithm
257 2486 sjacqu01
258 2486 sjacqu01
    // pull the names to the boost namespace
259 2486 sjacqu01
    using algorithm::first_finder;
260 2486 sjacqu01
    using algorithm::last_finder;
261 2486 sjacqu01
    using algorithm::nth_finder;
262 2486 sjacqu01
    using algorithm::head_finder;
263 2486 sjacqu01
    using algorithm::tail_finder;
264 2486 sjacqu01
    using algorithm::token_finder;
265 2486 sjacqu01
    using algorithm::range_finder;
266 2486 sjacqu01
267 2486 sjacqu01
} // namespace boost
268 2486 sjacqu01
269 2486 sjacqu01
270 2486 sjacqu01
#endif  // BOOST_STRING_FINDER_HPP