/*============================================================================= Copyright (c) 2011-2019 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout 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) =============================================================================*/ #ifndef TOOLS_SPRIG_ALGORITHM_STRING_FIND_SKIP_HPP #define TOOLS_SPRIG_ALGORITHM_STRING_FIND_SKIP_HPP #include #include #include #include namespace sprig { // // skip_finder // template struct skip_finderF { private: Finder finder_; public: explicit skip_finderF(Finder const& finder) : finder_(finder) {} template boost::iterator_range operator()(ForwardIterator first, ForwardIterator last) const { return boost::iterator_range(boost::end(finder_(first, last)), last); } }; template inline sprig::skip_finderF skip_finder(Finder const& finder) { return sprig::skip_finderF(finder); } // // find_skip // template inline boost::iterator_range::type> find_skip(Range& input, Finder const& finder) { return boost::algorithm::find(input, sprig::skip_finder(finder)); } // // skip_backward_finder // template struct skip_backward_finderF { private: Finder finder_; public: explicit skip_backward_finderF(Finder const& finder) : finder_(finder) {} template boost::iterator_range operator()(ForwardIterator first, ForwardIterator last) const { return boost::iterator_range(first, boost::begin(finder_(first, last))); } }; template inline sprig::skip_backward_finderF skip_backward_finder(Finder const& finder) { return sprig::skip_backward_finderF(finder); } // // find_skip_backward // template inline boost::iterator_range::type> find_skip_backward(Range& input, Finder const& finder) { return boost::algorithm::find(input, sprig::skip_backward_finder(finder)); } } // namespace sprig #endif // #ifndef TOOLS_SPRIG_ALGORITHM_STRING_FIND_SKIP_HPP