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_KEY_ACTOR_HPP
0009 #define BOOST_SPIRIT_ACTOR_INSERT_KEY_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 
0014 namespace boost { namespace spirit {
0015 
0016 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0017 
0018     ///////////////////////////////////////////////////////////////////////////
0019     //  Summary:
0020     //  A semantic action policy that insert data into an associative
0021     //  container using a const reference to data.
0022     //  (This doc uses convention available in actors.hpp)
0023     //
0024     //  Actions (what it does):
0025     //      ref.insert( T::value_type(value,value_ref) );
0026     //      ref.insert( T::value_type(T::key_type(first,last), value_ref));;
0027     //
0028     //  Policy name:
0029     //      insert_key_action
0030     //
0031     //  Policy holder, corresponding helper method:
0032     //      ref_const_ref_value_actor, insert_key_a( ref, value_ref );
0033     //
0034     //  () operators: both
0035     //
0036     //  See also ref_const_ref_value_actor for more details.
0037     ///////////////////////////////////////////////////////////////////////////
0038     struct insert_key_action
0039     {
0040         template<
0041             typename T,
0042             typename ValueT,
0043             typename ReferentT
0044         >
0045         void act(
0046             T& ref_,
0047             ValueT const& value_,
0048             ReferentT const& key_
0049             ) const
0050         {
0051             typedef typename T::value_type value_type;
0052             value_type key_value(key_, value_);
0053             ref_.insert( key_value );
0054         }
0055 
0056         template<
0057             typename T,
0058             typename ValueT,
0059             typename IteratorT
0060         >
0061         void act(
0062             T& ref_,
0063             ValueT const& value_,
0064             IteratorT const& first_,
0065             IteratorT const& last_
0066             ) const
0067         {
0068             typedef typename T::key_type key_type;
0069             typedef typename T::value_type value_type;
0070 
0071             key_type key(first_,last_);
0072             value_type key_value(key, value_);
0073             ref_.insert( key_value );
0074         }
0075     };
0076 
0077     template<
0078         typename T,
0079         typename ValueT
0080         >
0081     inline ref_const_ref_value_actor<T,ValueT,insert_key_action> insert_key_a(
0082         T& ref_,
0083         ValueT const& value_
0084         )
0085     {
0086         return ref_const_ref_value_actor<
0087             T,
0088             ValueT,
0089             insert_key_action
0090             >(ref_,value_);
0091     }
0092 
0093 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0094 
0095 }}
0096 
0097 #endif