1 /////////////////////////////////////////////////////////////////////////////// 2 // mark_begin_matcher.hpp 3 // 4 // Copyright 2008 Eric Niebler. Distributed under the Boost 5 // Software License, Version 1.0. (See accompanying file 6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 8 #ifndef BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_MARK_BEGIN_MATCHER_HPP_EAN_10_04_2005 9 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_MARK_BEGIN_MATCHER_HPP_EAN_10_04_2005 10 11 // MS compatible compilers support #pragma once 12 #if defined(_MSC_VER) 13 # pragma once 14 #endif 15 16 #include <boost/xpressive/detail/detail_fwd.hpp> 17 #include <boost/xpressive/detail/core/quant_style.hpp> 18 #include <boost/xpressive/detail/core/state.hpp> 19 20 namespace boost { namespace xpressive { namespace detail 21 { 22 23 /////////////////////////////////////////////////////////////////////////////// 24 // mark_begin_matcher 25 // 26 struct mark_begin_matcher 27 : quant_style<quant_fixed_width, 0, false> 28 { 29 int mark_number_; // signed because it could be negative 30 mark_begin_matcherboost::xpressive::detail::mark_begin_matcher31 mark_begin_matcher(int mark_number) 32 : mark_number_(mark_number) 33 { 34 } 35 36 template<typename BidiIter, typename Next> matchboost::xpressive::detail::mark_begin_matcher37 bool match(match_state<BidiIter> &state, Next const &next) const 38 { 39 sub_match_impl<BidiIter> &br = state.sub_match(this->mark_number_); 40 41 BidiIter old_begin = br.begin_; 42 br.begin_ = state.cur_; 43 44 if(next.match(state)) 45 { 46 return true; 47 } 48 49 br.begin_ = old_begin; 50 return false; 51 } 52 }; 53 54 }}} 55 56 #endif 57