Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:01:52

0001 /*=============================================================================
0002     Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
0003     http://spirit.sourceforge.net/
0004 
0005   Distributed under the Boost Software License, Version 1.0. (See accompanying
0006   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 =============================================================================*/
0008 #ifndef BOOST_SPIRIT_ACTOR_PUSH_BACK_ACTOR_HPP
0009 #define BOOST_SPIRIT_ACTOR_PUSH_BACK_ACTOR_HPP
0010 
0011 #include <boost/spirit/home/classic/namespace.hpp>
0012 #include <boost/spirit/home/classic/actor/ref_value_actor.hpp>
0013 #include <boost/spirit/home/classic/actor/ref_const_ref_actor.hpp>
0014 
0015 namespace boost { namespace spirit {
0016 
0017 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0018 
0019     ///////////////////////////////////////////////////////////////////////////
0020     //  Summary:
0021     //
0022     //  A semantic action policy that appends a value to the back of a
0023     //  container.
0024     //  (This doc uses convention available in actors.hpp)
0025     //
0026     //  Actions (what it does and what ref, value_ref must support):
0027     //      ref.push_back( value );
0028     //      ref.push_back( T::value_type(first,last) );
0029     //      ref.push_back( value_ref );
0030     //
0031     //  Policy name:
0032     //      push_back_action
0033     //
0034     //  Policy holder, corresponding helper method:
0035     //      ref_value_actor, push_back_a( ref );
0036     //      ref_const_ref_actor, push_back_a( ref, value_ref );
0037     //
0038     //  () operators: both
0039     //
0040     //  See also ref_value_actor and ref_const_ref_actor for more details.
0041     ///////////////////////////////////////////////////////////////////////////
0042     struct push_back_action
0043     {
0044         template<
0045             typename T,
0046             typename ValueT
0047         >
0048         void act(T& ref_, ValueT const& value_) const
0049         {
0050             ref_.push_back( value_ );
0051         }
0052         template<
0053             typename T,
0054             typename IteratorT
0055         >
0056         void act(
0057             T& ref_,
0058             IteratorT const& first_,
0059             IteratorT const& last_
0060             ) const
0061         {
0062             typedef typename T::value_type value_type;
0063             value_type value(first_,last_);
0064 
0065             ref_.push_back( value );
0066         }
0067     };
0068 
0069 //  Deprecated interface. Use push_back_a
0070     template<typename T>
0071     inline ref_value_actor<T,push_back_action> 
0072     append(T& ref_)
0073     {
0074         return ref_value_actor<T,push_back_action>(ref_);
0075     }
0076 
0077     template<typename T>
0078     inline ref_value_actor<T,push_back_action> 
0079     push_back_a(T& ref_)
0080     {
0081         return ref_value_actor<T,push_back_action>(ref_);
0082     }
0083 
0084     template<
0085         typename T,
0086         typename ValueT
0087     >
0088     inline ref_const_ref_actor<T,ValueT,push_back_action> 
0089     push_back_a(
0090         T& ref_,
0091         ValueT const& value_
0092     )
0093     {
0094         return ref_const_ref_actor<T,ValueT,push_back_action>(ref_,value_);
0095     }
0096 
0097 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0098 
0099 }}
0100 
0101 #endif