]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/xpressive/detail/core/matcher/range_matcher.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / xpressive / detail / core / matcher / range_matcher.hpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // range_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_RANGE_MATCHER_HPP_EAN_10_04_2005
9 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_RANGE_MATCHER_HPP_EAN_10_04_2005
10
11 // MS compatible compilers support #pragma once
12 #if defined(_MSC_VER)
13 # pragma once
14 # pragma warning(push)
15 # pragma warning(disable : 4100) // unreferenced formal parameter
16 #endif
17
18 #include <boost/mpl/bool.hpp>
19 #include <boost/xpressive/detail/detail_fwd.hpp>
20 #include <boost/xpressive/detail/core/quant_style.hpp>
21 #include <boost/xpressive/detail/core/state.hpp>
22
23 namespace boost { namespace xpressive { namespace detail
24 {
25
26 ///////////////////////////////////////////////////////////////////////////////
27 // range_matcher
28 //
29 template<typename Traits, typename ICase>
30 struct range_matcher
31 : quant_style_fixed_width<1>
32 {
33 typedef typename Traits::char_type char_type;
34 typedef ICase icase_type;
35 char_type ch_min_;
36 char_type ch_max_;
37 bool not_;
38
39 range_matcher(char_type ch_min, char_type ch_max, bool no, Traits const &)
40 : ch_min_(ch_min)
41 , ch_max_(ch_max)
42 , not_(no)
43 {
44 }
45
46 void inverse()
47 {
48 this->not_ = !this->not_;
49 }
50
51 bool in_range(Traits const &tr, char_type ch, mpl::false_) const // case-sensitive
52 {
53 return tr.in_range(this->ch_min_, this->ch_max_, ch);
54 }
55
56 bool in_range(Traits const &tr, char_type ch, mpl::true_) const // case-insensitive
57 {
58 return tr.in_range_nocase(this->ch_min_, this->ch_max_, ch);
59 }
60
61 template<typename BidiIter, typename Next>
62 bool match(match_state<BidiIter> &state, Next const &next) const
63 {
64 if(state.eos() || this->not_ ==
65 this->in_range(traits_cast<Traits>(state), *state.cur_, icase_type()))
66 {
67 return false;
68 }
69
70 ++state.cur_;
71 if(next.match(state))
72 {
73 return true;
74 }
75
76 --state.cur_;
77 return false;
78 }
79 };
80
81 }}}
82
83 #if defined(_MSC_VER)
84 # pragma warning(pop)
85 #endif
86
87 #endif