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_FRONT_ACTOR_HPP
9 #define BOOST_SPIRIT_ACTOR_PUSH_FRONT_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 front 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_front( value );
28 // ref.push_front( T::value_type(first,last) );
29 // ref.push_front( value_ref );
34 // Policy holder, corresponding helper method:
35 // ref_value_actor, push_front_a( ref );
36 // ref_const_ref_actor, push_front_a( ref, value_ref );
40 // See also ref_value_actor and ref_const_ref_actor for more details.
41 ///////////////////////////////////////////////////////////////////////////
42 struct push_front_action
48 void act(T& ref_, ValueT const& value_) const
50 ref_.push_front( 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_front( value );
70 inline ref_value_actor<T,push_front_action> push_front_a(T& ref_)
72 return ref_value_actor<T,push_front_action>(ref_);
79 inline ref_const_ref_actor<T,ValueT,push_front_action> push_front_a(
84 return ref_const_ref_actor<T,ValueT,push_front_action>(ref_,value_);
87 BOOST_SPIRIT_CLASSIC_NAMESPACE_END