1 ///////////////////////////////////////////////////////////////////////////////
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)
8 #ifndef BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_REGEX_MATCHER_HPP_EAN_10_04_2005
9 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_REGEX_MATCHER_HPP_EAN_10_04_2005
11 // MS compatible compilers support #pragma once
16 #include <boost/mpl/assert.hpp>
17 #include <boost/xpressive/regex_error.hpp>
18 #include <boost/xpressive/regex_constants.hpp>
19 #include <boost/xpressive/detail/core/regex_impl.hpp>
20 #include <boost/xpressive/detail/detail_fwd.hpp>
21 #include <boost/xpressive/detail/core/quant_style.hpp>
22 #include <boost/xpressive/detail/core/state.hpp>
23 #include <boost/xpressive/detail/core/adaptor.hpp>
25 namespace boost { namespace xpressive { namespace detail
28 ///////////////////////////////////////////////////////////////////////////////
31 template<typename BidiIter>
33 : quant_style<quant_variable_width, unknown_width::value, false>
35 regex_impl<BidiIter> impl_;
37 regex_matcher(shared_ptr<regex_impl<BidiIter> > const &impl)
40 this->impl_.xpr_ = impl->xpr_;
41 this->impl_.traits_ = impl->traits_;
42 this->impl_.mark_count_ = impl->mark_count_;
43 this->impl_.hidden_mark_count_ = impl->hidden_mark_count_;
45 BOOST_XPR_ENSURE_(this->impl_.xpr_, regex_constants::error_badref, "bad regex reference");
48 template<typename Next>
49 bool match(match_state<BidiIter> &state, Next const &next) const
51 // regex_matcher is used for embeding a dynamic regex in a static regex. As such,
52 // Next will always point to a static regex.
53 BOOST_MPL_ASSERT((is_static_xpression<Next>));
55 // wrap the static xpression in a matchable interface
56 xpression_adaptor<reference_wrapper<Next const>, matchable<BidiIter> > adaptor(boost::cref(next));
57 return push_context_match(this->impl_, state, adaptor);