Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:48

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // posix_charset_matcher.hpp
0003 //
0004 //  Copyright 2008 Eric Niebler. Distributed under the Boost
0005 //  Software License, Version 1.0. (See accompanying file
0006 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 #ifndef BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_POSIX_CHARSET_MATCHER_HPP_EAN_10_04_2005
0009 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_POSIX_CHARSET_MATCHER_HPP_EAN_10_04_2005
0010 
0011 // MS compatible compilers support #pragma once
0012 #if defined(_MSC_VER)
0013 # pragma once
0014 #endif
0015 
0016 #include <boost/assert.hpp>
0017 #include <boost/mpl/bool.hpp>
0018 #include <boost/xpressive/detail/detail_fwd.hpp>
0019 #include <boost/xpressive/detail/core/quant_style.hpp>
0020 #include <boost/xpressive/detail/core/state.hpp>
0021 #include <boost/xpressive/detail/utility/traits_utils.hpp>
0022 
0023 namespace boost { namespace xpressive { namespace detail
0024 {
0025 
0026     ///////////////////////////////////////////////////////////////////////////////
0027     // posix_charset_matcher
0028     //
0029     template<typename Traits>
0030     struct posix_charset_matcher
0031       : quant_style_fixed_width<1>
0032     {
0033         typedef Traits traits_type;
0034         typedef typename Traits::char_class_type char_class_type;
0035 
0036         posix_charset_matcher(char_class_type m, bool no)
0037           : not_(no)
0038           , mask_(m)
0039         {
0040             BOOST_ASSERT(0 != this->mask_);
0041         }
0042 
0043         void inverse()
0044         {
0045             this->not_ = !this->not_;
0046         }
0047 
0048         template<typename BidiIter, typename Next>
0049         bool match(match_state<BidiIter> &state, Next const &next) const
0050         {
0051             if(state.eos() || this->not_ == traits_cast<Traits>(state).isctype(
0052                 *state.cur_, this->mask_))
0053             {
0054                 return false;
0055             }
0056 
0057             ++state.cur_;
0058             if(next.match(state))
0059             {
0060                 return true;
0061             }
0062 
0063             --state.cur_;
0064             return false;
0065         }
0066 
0067         bool not_;
0068         char_class_type mask_;
0069     };
0070 
0071 }}}
0072 
0073 #endif