File indexing completed on 2025-01-18 09:53:49
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_XPRESSIVE_DETAIL_SET_HPP_EAN_10_04_2005
0009 #define BOOST_XPRESSIVE_DETAIL_SET_HPP_EAN_10_04_2005
0010
0011
0012 #if defined(_MSC_VER)
0013 # pragma once
0014 # pragma warning(push)
0015 # pragma warning(disable : 4127)
0016 # pragma warning(disable : 4100)
0017 # pragma warning(disable : 4351)
0018 #endif
0019
0020 #include <algorithm>
0021 #include <boost/mpl/assert.hpp>
0022 #include <boost/type_traits/same_traits.hpp>
0023 #include <boost/xpressive/detail/detail_fwd.hpp>
0024 #include <boost/xpressive/detail/core/quant_style.hpp>
0025 #include <boost/xpressive/detail/core/state.hpp>
0026
0027 namespace boost { namespace xpressive { namespace detail
0028 {
0029
0030
0031
0032
0033 template<typename Traits, typename Size>
0034 struct set_matcher
0035 : quant_style_fixed_width<1>
0036 {
0037 typedef typename Traits::char_type char_type;
0038 char_type set_[ Size::value ];
0039 bool not_;
0040 bool icase_;
0041
0042 set_matcher()
0043 : set_()
0044 , not_(false)
0045 , icase_(false)
0046 {
0047 }
0048
0049 void inverse()
0050 {
0051 this->not_ = !this->not_;
0052 }
0053
0054 void nocase(Traits const &tr)
0055 {
0056 this->icase_ = true;
0057
0058 for(int i = 0; i < Size::value; ++i)
0059 {
0060 this->set_[i] = tr.translate_nocase(this->set_[i]);
0061 }
0062 }
0063
0064 bool in_set(Traits const &tr, char_type ch) const
0065 {
0066 char_type const *begin = &this->set_[0], *end = begin + Size::value;
0067 ch = this->icase_ ? tr.translate_nocase(ch) : tr.translate(ch);
0068 return end != std::find(begin, end, ch);
0069 }
0070
0071 template<typename BidiIter, typename Next>
0072 bool match(match_state<BidiIter> &state, Next const &next) const
0073 {
0074 if(state.eos() || this->not_ == this->in_set(traits_cast<Traits>(state), *state.cur_))
0075 {
0076 return false;
0077 }
0078
0079 if(++state.cur_, next.match(state))
0080 {
0081 return true;
0082 }
0083
0084 return --state.cur_, false;
0085 }
0086 };
0087
0088
0089
0090 struct set_initializer
0091 {
0092 };
0093
0094 #if defined(_MSC_VER)
0095 # pragma warning(pop)
0096 #endif
0097
0098 }}}
0099
0100 #endif