File indexing completed on 2025-01-18 09:53:48
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_RANGE_MATCHER_HPP_EAN_10_04_2005
0009 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_RANGE_MATCHER_HPP_EAN_10_04_2005
0010
0011
0012 #if defined(_MSC_VER)
0013 # pragma once
0014 # pragma warning(push)
0015 # pragma warning(disable : 4100)
0016 #endif
0017
0018 #include <boost/mpl/bool.hpp>
0019 #include <boost/xpressive/detail/detail_fwd.hpp>
0020 #include <boost/xpressive/detail/core/quant_style.hpp>
0021 #include <boost/xpressive/detail/core/state.hpp>
0022
0023 namespace boost { namespace xpressive { namespace detail
0024 {
0025
0026
0027
0028
0029 template<typename Traits, typename ICase>
0030 struct range_matcher
0031 : quant_style_fixed_width<1>
0032 {
0033 typedef typename Traits::char_type char_type;
0034 typedef ICase icase_type;
0035 char_type ch_min_;
0036 char_type ch_max_;
0037 bool not_;
0038
0039 range_matcher(char_type ch_min, char_type ch_max, bool no, Traits const &)
0040 : ch_min_(ch_min)
0041 , ch_max_(ch_max)
0042 , not_(no)
0043 {
0044 }
0045
0046 void inverse()
0047 {
0048 this->not_ = !this->not_;
0049 }
0050
0051 bool in_range(Traits const &tr, char_type ch, mpl::false_) const
0052 {
0053 return tr.in_range(this->ch_min_, this->ch_max_, ch);
0054 }
0055
0056 bool in_range(Traits const &tr, char_type ch, mpl::true_) const
0057 {
0058 return tr.in_range_nocase(this->ch_min_, this->ch_max_, ch);
0059 }
0060
0061 template<typename BidiIter, typename Next>
0062 bool match(match_state<BidiIter> &state, Next const &next) const
0063 {
0064 if(state.eos() || this->not_ ==
0065 this->in_range(traits_cast<Traits>(state), *state.cur_, icase_type()))
0066 {
0067 return false;
0068 }
0069
0070 ++state.cur_;
0071 if(next.match(state))
0072 {
0073 return true;
0074 }
0075
0076 --state.cur_;
0077 return false;
0078 }
0079 };
0080
0081 }}}
0082
0083 #if defined(_MSC_VER)
0084 # pragma warning(pop)
0085 #endif
0086
0087 #endif