File indexing completed on 2025-01-18 09:53:48
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_MARK_MATCHER_HPP_EAN_10_04_2005
0009 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_MARK_MATCHER_HPP_EAN_10_04_2005
0010
0011
0012 #if defined(_MSC_VER)
0013 # pragma once
0014 #endif
0015
0016 #include <boost/assert.hpp>
0017 #include <boost/xpressive/detail/detail_fwd.hpp>
0018 #include <boost/xpressive/detail/core/quant_style.hpp>
0019 #include <boost/xpressive/detail/core/state.hpp>
0020 #include <boost/xpressive/detail/utility/traits_utils.hpp>
0021
0022 namespace boost { namespace xpressive { namespace detail
0023 {
0024
0025
0026
0027
0028
0029
0030
0031 template<typename Traits, typename ICase>
0032 struct mark_matcher
0033 : quant_style_variable_width
0034 {
0035 typedef ICase icase_type;
0036 int mark_number_;
0037
0038 mark_matcher(int mark_number, Traits const &)
0039 : mark_number_(mark_number)
0040 {
0041 }
0042
0043 template<typename BidiIter, typename Next>
0044 bool match(match_state<BidiIter> &state, Next const &next) const
0045 {
0046 BOOST_ASSERT(this->mark_number_ < static_cast<int>(state.mark_count_));
0047 sub_match_impl<BidiIter> const &br = state.sub_match(this->mark_number_);
0048
0049 if(!br.matched)
0050 {
0051 return false;
0052 }
0053
0054 BidiIter const tmp = state.cur_;
0055 for(BidiIter begin = br.first, end = br.second; begin != end; ++begin, ++state.cur_)
0056 {
0057 if(state.eos()
0058 || detail::translate(*state.cur_, traits_cast<Traits>(state), icase_type())
0059 != detail::translate(*begin, traits_cast<Traits>(state), icase_type()))
0060 {
0061 state.cur_ = tmp;
0062 return false;
0063 }
0064 }
0065
0066 if(next.match(state))
0067 {
0068 return true;
0069 }
0070
0071 state.cur_ = tmp;
0072 return false;
0073 }
0074 };
0075
0076 }}}
0077
0078 #endif