File indexing completed on 2025-01-18 09:53:48
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_REGEX_BYREF_MATCHER_HPP_EAN_10_04_2005
0009 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_REGEX_BYREF_MATCHER_HPP_EAN_10_04_2005
0010
0011
0012 #if defined(_MSC_VER)
0013 # pragma once
0014 #endif
0015
0016 #include <boost/assert.hpp>
0017 #include <boost/mpl/assert.hpp>
0018 #include <boost/shared_ptr.hpp>
0019 #include <boost/xpressive/regex_error.hpp>
0020 #include <boost/xpressive/regex_constants.hpp>
0021 #include <boost/xpressive/detail/detail_fwd.hpp>
0022 #include <boost/xpressive/detail/core/quant_style.hpp>
0023 #include <boost/xpressive/detail/core/state.hpp>
0024 #include <boost/xpressive/detail/core/regex_impl.hpp>
0025 #include <boost/xpressive/detail/core/adaptor.hpp>
0026
0027 namespace boost { namespace xpressive { namespace detail
0028 {
0029
0030
0031
0032 template<typename BidiIter>
0033 struct regex_byref_matcher
0034 : quant_style<quant_variable_width, unknown_width::value, false>
0035 {
0036
0037
0038 weak_ptr<regex_impl<BidiIter> > wimpl_;
0039
0040
0041
0042 regex_impl<BidiIter> const *pimpl_;
0043
0044 regex_byref_matcher(shared_ptr<regex_impl<BidiIter> > const &impl)
0045 : wimpl_(impl)
0046 , pimpl_(impl.get())
0047 {
0048 BOOST_ASSERT(this->pimpl_);
0049 }
0050
0051 template<typename Next>
0052 bool match(match_state<BidiIter> &state, Next const &next) const
0053 {
0054 BOOST_ASSERT(this->pimpl_ == this->wimpl_.lock().get());
0055 BOOST_XPR_ENSURE_(this->pimpl_->xpr_, regex_constants::error_badref, "bad regex reference");
0056
0057 return push_context_match(*this->pimpl_, state, this->wrap_(next, is_static_xpression<Next>()));
0058 }
0059
0060 private:
0061 template<typename Next>
0062 static xpression_adaptor<reference_wrapper<Next const>, matchable<BidiIter> > wrap_(Next const &next, mpl::true_)
0063 {
0064
0065 return xpression_adaptor<reference_wrapper<Next const>, matchable<BidiIter> >(boost::cref(next));
0066 }
0067
0068 template<typename Next>
0069 static Next const &wrap_(Next const &next, mpl::false_)
0070 {
0071 return next;
0072 }
0073 };
0074
0075 }}}
0076
0077 #endif