]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/xpressive/detail/core/matcher/posix_charset_matcher.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / xpressive / detail / core / matcher / posix_charset_matcher.hpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // posix_charset_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_POSIX_CHARSET_MATCHER_HPP_EAN_10_04_2005
9 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_POSIX_CHARSET_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/assert.hpp>
17 #include <boost/mpl/bool.hpp>
18 #include <boost/xpressive/detail/detail_fwd.hpp>
19 #include <boost/xpressive/detail/core/quant_style.hpp>
20 #include <boost/xpressive/detail/core/state.hpp>
21 #include <boost/xpressive/detail/utility/traits_utils.hpp>
22
23 namespace boost { namespace xpressive { namespace detail
24 {
25
26 ///////////////////////////////////////////////////////////////////////////////
27 // posix_charset_matcher
28 //
29 template<typename Traits>
30 struct posix_charset_matcher
31 : quant_style_fixed_width<1>
32 {
33 typedef Traits traits_type;
34 typedef typename Traits::char_class_type char_class_type;
35
36 posix_charset_matcher(char_class_type m, bool no)
37 : not_(no)
38 , mask_(m)
39 {
40 BOOST_ASSERT(0 != this->mask_);
41 }
42
43 void inverse()
44 {
45 this->not_ = !this->not_;
46 }
47
48 template<typename BidiIter, typename Next>
49 bool match(match_state<BidiIter> &state, Next const &next) const
50 {
51 if(state.eos() || this->not_ == traits_cast<Traits>(state).isctype(
52 *state.cur_, this->mask_))
53 {
54 return false;
55 }
56
57 ++state.cur_;
58 if(next.match(state))
59 {
60 return true;
61 }
62
63 --state.cur_;
64 return false;
65 }
66
67 bool not_;
68 char_class_type mask_;
69 };
70
71 }}}
72
73 #endif