1 /*============================================================================= 2 Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com) 3 http://spirit.sourceforge.net/ 4 5 Distributed under the Boost Software License, Version 1.0. (See accompanying 6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 =============================================================================*/ 8 #ifndef BOOST_SPIRIT_ACTOR_REF_CONST_REF_ACTOR_HPP 9 #define BOOST_SPIRIT_ACTOR_REF_CONST_REF_ACTOR_HPP 10 11 #include <boost/spirit/home/classic/namespace.hpp> 12 13 namespace boost { namespace spirit { 14 15 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN 16 17 /////////////////////////////////////////////////////////////////////////// 18 // Summary: 19 // A semantic action policy holder. This holder stores a reference to ref 20 // and a const reference to value_ref. 21 // act methods are feed with ref and value_ref. The parse result is 22 // not used by this holder. 23 // 24 // (This doc uses convention available in actors.hpp) 25 // 26 // Constructor: 27 // ...(T& ref_, ValueT const& value_ref_); 28 // where ref_ and value_ref_ are stored in the holder. 29 // 30 // Action calls: 31 // act(ref, value_ref); 32 // 33 // () operators: both 34 // 35 /////////////////////////////////////////////////////////////////////////// 36 template< 37 typename T, 38 typename ValueT, 39 typename ActionT 40 > 41 class ref_const_ref_actor : public ActionT 42 { 43 private: 44 T& ref; 45 ValueT const& value_ref; 46 public: ref_const_ref_actor(T & ref_,ValueT const & value_ref_)47 ref_const_ref_actor( 48 T& ref_, 49 ValueT const& value_ref_ 50 ) 51 : 52 ref(ref_), 53 value_ref(value_ref_) 54 {} 55 56 57 template<typename T2> operator ()(T2 const &) const58 void operator()(T2 const& /*val*/) const 59 { 60 this->act(ref,value_ref); // defined in ActionT 61 } 62 63 64 template<typename IteratorT> operator ()(IteratorT const &,IteratorT const &) const65 void operator()( 66 IteratorT const& /*first*/, 67 IteratorT const& /*last*/ 68 ) const 69 { 70 this->act(ref,value_ref); // defined in ActionT 71 } 72 }; 73 74 BOOST_SPIRIT_CLASSIC_NAMESPACE_END 75 76 }} 77 78 #endif 79