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