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_INSERT_AT_ACTOR_HPP
0009 #define BOOST_SPIRIT_ACTOR_INSERT_AT_ACTOR_HPP
0010 
0011 #include <boost/spirit/home/classic/namespace.hpp>
0012 #include <boost/spirit/home/classic/actor/ref_const_ref_value_actor.hpp>
0013 #include <boost/spirit/home/classic/actor/ref_const_ref_const_ref_a.hpp>
0014 
0015 namespace boost { namespace spirit {
0016 
0017 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0018 
0019     ///////////////////////////////////////////////////////////////////////////
0020     //  Summary:
0021     //  A semantic action policy that insert data into an associative 
0022     //  container using a const reference to a key.
0023     //  (This doc uses convention available in actors.hpp)
0024     //
0025     //  Actions (what it does):
0026     //      ref.insert( T::value_type(key_ref,value) );
0027     //      ref.insert( T::value_type(key_ref, T::mapped_type(first,last)));;
0028     //      ref.insert( T::value_type(key_ref,value_ref) );
0029     //
0030     //  Policy name:
0031     //      insert_at_action
0032     //
0033     //  Policy holder, corresponding helper method:
0034     //      ref_const_ref_value_actor, insert_at_a( ref, key_ref ); 
0035     //      ref_const_ref_const_ref_actor, insert_a( ref, key_ref, value_ref );
0036     //
0037     //  () operators: both
0038     //
0039     //  See also ref_const_ref_value_actor and ref_const_ref_const_ref_actor 
0040     //  for more details.
0041     ///////////////////////////////////////////////////////////////////////////
0042     struct insert_at_action
0043     {
0044         template<
0045             typename T,
0046             typename ReferentT,
0047             typename ValueT
0048         >
0049         void act(
0050             T& ref_, 
0051             ReferentT const& key_,
0052             ValueT const& value_
0053             ) const
0054         {
0055             typedef typename T::value_type value_type;
0056             ref_.insert( value_type(key_, value_) );
0057         }
0058 
0059         template<
0060             typename T,
0061             typename ReferentT,
0062             typename IteratorT
0063         >
0064         void act(
0065             T& ref_, 
0066             ReferentT const& key_,
0067             IteratorT const& first_, 
0068             IteratorT const& last_
0069             ) const
0070         {
0071             typedef typename T::mapped_type mapped_type;
0072             typedef typename T::value_type value_type;
0073 
0074             mapped_type value(first_,last_);
0075             value_type key_value(key_, value);
0076             ref_.insert( key_value );
0077         }
0078     };
0079 
0080     template<
0081         typename T,
0082         typename ReferentT
0083         >
0084     inline ref_const_ref_value_actor<T,ReferentT,insert_at_action> 
0085     insert_at_a(
0086             T& ref_,
0087             ReferentT const& key_
0088         )
0089     {
0090         return ref_const_ref_value_actor<
0091             T,
0092             ReferentT,
0093             insert_at_action
0094             >(ref_,key_);
0095     }
0096 
0097     template<
0098         typename T,
0099         typename ReferentT,
0100         typename ValueT
0101     >
0102     inline ref_const_ref_const_ref_actor<T,ReferentT,ValueT,insert_at_action> 
0103     insert_at_a(
0104                 T& ref_,
0105                 ReferentT const& key_,
0106                 ValueT const& value_
0107             )
0108     {
0109         return ref_const_ref_const_ref_actor<
0110             T,
0111             ReferentT,
0112             ValueT,
0113             insert_at_action
0114             >(ref_,key_,value_);
0115     }
0116 
0117 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0118 
0119 }}
0120 
0121 #endif