source: NonGTP/Boost/boost/algorithm/string/detail/find_iterator.hpp @ 857

Revision 857, 2.8 KB checked in by igarcia, 18 years ago (diff)
Line 
1//  Boost string_algo library find_iterator.hpp header file  ---------------------------//
2
3//  Copyright Pavol Droba 2002-2003. Use, modification and
4//  distribution is subject to the Boost Software License, Version
5//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
6//  http://www.boost.org/LICENSE_1_0.txt)
7
8//  See http://www.boost.org for updates, documentation, and revision history.
9
10#ifndef BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
11#define BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
12
13#include <boost/algorithm/string/config.hpp>
14#include <boost/range/iterator_range.hpp>
15#include <boost/iterator/iterator_facade.hpp>
16#include <boost/iterator/iterator_categories.hpp>
17#include <boost/function.hpp>
18
19namespace boost {
20    namespace algorithm {
21        namespace detail {
22
23//  find_iterator base -----------------------------------------------//
24
25            // Find iterator base
26            template<typename IteratorT>
27            class find_iterator_base
28            {
29            protected:
30                // typedefs
31                typedef IteratorT input_iterator_type;
32                typedef iterator_range<IteratorT> match_type;
33                typedef function2<
34                    match_type,
35                    input_iterator_type,
36                    input_iterator_type> finder_type;
37               
38            protected:
39            // Protected construction/destruction
40
41                // Default constructor
42                find_iterator_base() {};
43                // Copy construction
44                find_iterator_base( const find_iterator_base& Other ) :
45                    m_Finder(Other.m_Finder) {}
46               
47                // Constructor
48                template<typename FinderT>
49                find_iterator_base( FinderT Finder, int ) :
50                    m_Finder(Finder) {}
51
52                // Destructor
53                ~find_iterator_base() {}
54
55                // Find operation
56                match_type do_find(
57                    input_iterator_type Begin,
58                    input_iterator_type End ) const
59                {
60                    if (!m_Finder.empty())
61                    {
62                        return m_Finder(Begin,End);
63                    }
64                    else
65                    {
66                        return match_type(End,End);
67                    }
68                }
69
70                // Check
71                bool is_null() const
72                {
73                    return m_Finder.empty();
74                }
75
76            private:
77                // Finder
78                finder_type m_Finder;
79            };
80
81       } // namespace detail
82    } // namespace algorithm
83} // namespace boost
84
85
86#endif  // BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
Note: See TracBrowser for help on using the repository browser.