Back to home page

EIC code displayed by LXR

 
 

    


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

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // literal_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_LITERAL_MATCHER_HPP_EAN_10_04_2005
0009 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_LITERAL_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/xpressive/detail/detail_fwd.hpp>
0017 #include <boost/xpressive/detail/core/quant_style.hpp>
0018 #include <boost/xpressive/detail/core/state.hpp>
0019 #include <boost/xpressive/detail/utility/traits_utils.hpp>
0020 
0021 namespace boost { namespace xpressive { namespace detail
0022 {
0023 
0024     ///////////////////////////////////////////////////////////////////////////////
0025     // literal_matcher
0026     //
0027     template<typename Traits, typename ICase, typename Not>
0028     struct literal_matcher
0029       : quant_style_fixed_width<1>
0030     {
0031         typedef typename Traits::char_type char_type;
0032         typedef Not not_type;
0033         typedef ICase icase_type;
0034         char_type ch_;
0035 
0036         explicit literal_matcher(char_type ch)
0037           : ch_(ch)
0038         {}
0039 
0040         literal_matcher(char_type ch, Traits const &tr)
0041           : ch_(detail::translate(ch, tr, icase_type()))
0042         {}
0043 
0044         template<typename BidiIter, typename Next>
0045         bool match(match_state<BidiIter> &state, Next const &next) const
0046         {
0047             if(state.eos() || Not::value ==
0048                 (detail::translate(*state.cur_, traits_cast<Traits>(state), icase_type()) == this->ch_))
0049             {
0050                 return false;
0051             }
0052 
0053             ++state.cur_;
0054             if(next.match(state))
0055             {
0056                 return true;
0057             }
0058 
0059             --state.cur_;
0060             return false;
0061         }
0062     };
0063 
0064 }}}
0065 
0066 #endif