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_VALUE_ACTOR_HPP
9 #define BOOST_SPIRIT_ACTOR_REF_CONST_REF_VALUE_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, value_ref and the parse result.
22     //
23     //  (This doc uses convention available in actors.hpp)
24     //
25     //  Constructor:
26     //      ...(T& ref_, ValueT const& value_ref_);
27     //      where ref_ and value_ref_ are stored in the holder.
28     //
29     //  Action calls:
30     //      act(ref, value_ref, value);
31     //      act(ref, value_ref, first, last);
32     //
33     //  () operators: both
34     //
35     ///////////////////////////////////////////////////////////////////////////
36     template<
37         typename T,
38         typename ValueT,
39         typename ActionT
40     >
41     class ref_const_ref_value_actor : public ActionT
42     {
43     private:
44         T& ref;
45         ValueT const& value_ref;
46     public:
ref_const_ref_value_actor(T & ref_,ValueT const & value_ref_)47         ref_const_ref_value_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 & val_) const58         void operator()(T2 const& val_) const
59         {
60             this->act(ref,value_ref,val_); // defined in ActionT
61         }
62 
63 
64         template<typename IteratorT>
operator ()(IteratorT const & first_,IteratorT const & last_) const65             void operator()(
66             IteratorT const& first_,
67             IteratorT const& last_
68             ) const
69         {
70             this->act(ref,value_ref,first_,last_); // defined in ActionT
71         }
72     };
73 
74 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
75 
76 }}
77 
78 #endif
79