Back to home page

EIC code displayed by LXR

 
 

    


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

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // regex_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_REGEX_MATCHER_HPP_EAN_10_04_2005
0009 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_REGEX_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/mpl/assert.hpp>
0017 #include <boost/xpressive/regex_error.hpp>
0018 #include <boost/xpressive/regex_constants.hpp>
0019 #include <boost/xpressive/detail/core/regex_impl.hpp>
0020 #include <boost/xpressive/detail/detail_fwd.hpp>
0021 #include <boost/xpressive/detail/core/quant_style.hpp>
0022 #include <boost/xpressive/detail/core/state.hpp>
0023 #include <boost/xpressive/detail/core/adaptor.hpp>
0024 
0025 namespace boost { namespace xpressive { namespace detail
0026 {
0027 
0028     ///////////////////////////////////////////////////////////////////////////////
0029     // regex_matcher
0030     //
0031     template<typename BidiIter>
0032     struct regex_matcher
0033       : quant_style<quant_variable_width, unknown_width::value, false>
0034     {
0035         regex_impl<BidiIter> impl_;
0036 
0037         regex_matcher(shared_ptr<regex_impl<BidiIter> > const &impl)
0038           : impl_()
0039         {
0040             this->impl_.xpr_ = impl->xpr_;
0041             this->impl_.traits_ = impl->traits_;
0042             this->impl_.mark_count_ = impl->mark_count_;
0043             this->impl_.hidden_mark_count_ = impl->hidden_mark_count_;
0044 
0045             BOOST_XPR_ENSURE_(this->impl_.xpr_, regex_constants::error_badref, "bad regex reference");
0046         }
0047 
0048         template<typename Next>
0049         bool match(match_state<BidiIter> &state, Next const &next) const
0050         {
0051             // regex_matcher is used for embeding a dynamic regex in a static regex. As such,
0052             // Next will always point to a static regex.
0053             BOOST_MPL_ASSERT((is_static_xpression<Next>));
0054 
0055             // wrap the static xpression in a matchable interface
0056             xpression_adaptor<reference_wrapper<Next const>, matchable<BidiIter> > adaptor(boost::cref(next));
0057             return push_context_match(this->impl_, state, adaptor);
0058         }
0059     };
0060 
0061 }}}
0062 
0063 #endif