1 /*=============================================================================
2 Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
3 http://spirit.sourceforge.net/
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_PUSH_BACK_ACTOR_HPP
9 #define BOOST_SPIRIT_ACTOR_PUSH_BACK_ACTOR_HPP
11 #include <boost/spirit/home/classic/namespace.hpp>
12 #include <boost/spirit/home/classic/actor/ref_value_actor.hpp>
13 #include <boost/spirit/home/classic/actor/ref_const_ref_actor.hpp>
15 namespace boost { namespace spirit {
17 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
19 ///////////////////////////////////////////////////////////////////////////
22 // A semantic action policy that appends a value to the back of a
24 // (This doc uses convention available in actors.hpp)
26 // Actions (what it does and what ref, value_ref must support):
27 // ref.push_back( value );
28 // ref.push_back( T::value_type(first,last) );
29 // ref.push_back( value_ref );
34 // Policy holder, corresponding helper method:
35 // ref_value_actor, push_back_a( ref );
36 // ref_const_ref_actor, push_back_a( ref, value_ref );
40 // See also ref_value_actor and ref_const_ref_actor for more details.
41 ///////////////////////////////////////////////////////////////////////////
42 struct push_back_action
48 void act(T& ref_, ValueT const& value_) const
50 ref_.push_back( value_ );
58 IteratorT const& first_,
59 IteratorT const& last_
62 typedef typename T::value_type value_type;
63 value_type value(first_,last_);
65 ref_.push_back( value );
69 // Deprecated interface. Use push_back_a
71 inline ref_value_actor<T,push_back_action>
74 return ref_value_actor<T,push_back_action>(ref_);
78 inline ref_value_actor<T,push_back_action>
81 return ref_value_actor<T,push_back_action>(ref_);
88 inline ref_const_ref_actor<T,ValueT,push_back_action>
94 return ref_const_ref_actor<T,ValueT,push_back_action>(ref_,value_);
97 BOOST_SPIRIT_CLASSIC_NAMESPACE_END