source: NonGTP/Boost/boost/spirit/actor/ref_actor.hpp @ 857

Revision 857, 1.8 KB checked in by igarcia, 18 years ago (diff)
Line 
1/*=============================================================================
2    Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
3    http://spirit.sourceforge.net/
4
5    Use, modification and distribution is subject to the Boost Software
6    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7    http://www.boost.org/LICENSE_1_0.txt)
8=============================================================================*/
9#ifndef BOOST_SPIRIT_ACTOR_REF_ACTOR_HPP
10#define BOOST_SPIRIT_ACTOR_REF_ACTOR_HPP
11
12namespace boost { namespace spirit {
13
14    ///////////////////////////////////////////////////////////////////////////
15    //  Summary:
16    //  A semantic action policy holder. This holder stores a reference to ref,
17    //  act methods are fead with this reference. The parse result is not used
18    //  by this holder.
19    //
20    //  (This doc uses convention available in actors.hpp)
21    //
22    //  Constructor:
23    //      ...(T& ref_);
24    //      where ref_ is stored.
25    //
26    //  Action calls:
27    //      act(ref);
28    //
29    //  () operators: both
30    //
31    ///////////////////////////////////////////////////////////////////////////
32    template<
33        typename T,
34        typename ActionT
35    >
36    class ref_actor : public ActionT
37    {
38    private:
39        T& ref;
40    public:
41        explicit
42        ref_actor(T& ref_)
43        : ref(ref_){}
44
45
46        template<typename T2>
47        void operator()(T2 const& /*val*/) const
48        {
49            this->act(ref); // defined in ActionT
50        }
51
52
53        template<typename IteratorT>
54        void operator()(
55            IteratorT const& /*first*/,
56            IteratorT const& /*last*/
57            ) const
58        {
59            this->act(ref); // defined in ActionT
60        }
61    };
62
63}}
64
65#endif
Note: See TracBrowser for help on using the repository browser.