Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:24

0001 //  Boost string_algo library find_iterator.hpp header file  ---------------------------//
0002 
0003 //  Copyright Pavol Droba 2002-2003.
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 //    (See accompanying file LICENSE_1_0.txt or copy at
0007 //          http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 //  See http://www.boost.org/ for updates, documentation, and revision history.
0010 
0011 #ifndef BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
0012 #define BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
0013 
0014 #include <boost/algorithm/string/config.hpp>
0015 #include <boost/range/iterator_range_core.hpp>
0016 #include <boost/iterator/iterator_facade.hpp>
0017 #include <boost/iterator/iterator_categories.hpp>
0018 #include <boost/function.hpp>
0019 
0020 namespace boost {
0021     namespace algorithm { 
0022         namespace detail {
0023 
0024 //  find_iterator base -----------------------------------------------//
0025 
0026             // Find iterator base
0027             template<typename IteratorT>
0028             class find_iterator_base
0029             {
0030             protected:
0031                 // typedefs
0032                 typedef IteratorT input_iterator_type;
0033                 typedef iterator_range<IteratorT> match_type;
0034                 typedef function2<
0035                     match_type, 
0036                     input_iterator_type, 
0037                     input_iterator_type> finder_type;
0038                 
0039             protected:
0040             // Protected construction/destruction
0041 
0042                 // Default constructor
0043                 BOOST_DEFAULTED_FUNCTION(find_iterator_base(), {})
0044 
0045                 // Copy construction
0046                 BOOST_DEFAULTED_FUNCTION(find_iterator_base( const find_iterator_base& Other ), :
0047                     m_Finder(Other.m_Finder) {}
0048                 )
0049 
0050                 // Assignment
0051                 BOOST_DEFAULTED_FUNCTION(find_iterator_base& operator=( const find_iterator_base& Other ), {
0052                     m_Finder = Other.m_Finder;
0053                     return *this;
0054                 })
0055                 
0056                 // Constructor
0057                 template<typename FinderT>
0058                 find_iterator_base( FinderT Finder, int ) :
0059                     m_Finder(Finder) {}
0060 
0061                 // Destructor
0062                 BOOST_DEFAULTED_FUNCTION(~find_iterator_base(), {})
0063 
0064                 // Find operation
0065                 match_type do_find( 
0066                     input_iterator_type Begin,
0067                     input_iterator_type End ) const
0068                 {
0069                     if (!m_Finder.empty())
0070                     {
0071                         return m_Finder(Begin,End);
0072                     }
0073                     else
0074                     {
0075                         return match_type(End,End);
0076                     }
0077                 }
0078 
0079                 // Check
0080                 bool is_null() const
0081                 {
0082                     return m_Finder.empty();
0083                 }
0084 
0085             private:
0086                 // Finder
0087                 finder_type m_Finder;
0088             };
0089 
0090        } // namespace detail
0091     } // namespace algorithm
0092 } // namespace boost
0093 
0094 
0095 #endif  // BOOST_STRING_FIND_ITERATOR_DETAIL_HPP