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_INSERT_AT_ACTOR_HPP
9 #define BOOST_SPIRIT_ACTOR_INSERT_AT_ACTOR_HPP
11 #include <boost/spirit/home/classic/namespace.hpp>
12 #include <boost/spirit/home/classic/actor/ref_const_ref_value_actor.hpp>
13 #include <boost/spirit/home/classic/actor/ref_const_ref_const_ref_a.hpp>
15 namespace boost { namespace spirit {
17 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
19 ///////////////////////////////////////////////////////////////////////////
21 // A semantic action policy that insert data into an associative
22 // container using a const reference to a key.
23 // (This doc uses convention available in actors.hpp)
25 // Actions (what it does):
26 // ref.insert( T::value_type(key_ref,value) );
27 // ref.insert( T::value_type(key_ref, T::mapped_type(first,last)));;
28 // ref.insert( T::value_type(key_ref,value_ref) );
33 // Policy holder, corresponding helper method:
34 // ref_const_ref_value_actor, insert_at_a( ref, key_ref );
35 // ref_const_ref_const_ref_actor, insert_a( ref, key_ref, value_ref );
39 // See also ref_const_ref_value_actor and ref_const_ref_const_ref_actor
41 ///////////////////////////////////////////////////////////////////////////
42 struct insert_at_action
51 ReferentT const& key_,
55 typedef typename T::value_type value_type;
56 ref_.insert( value_type(key_, value_) );
66 ReferentT const& key_,
67 IteratorT const& first_,
68 IteratorT const& last_
71 typedef typename T::mapped_type mapped_type;
72 typedef typename T::value_type value_type;
74 mapped_type value(first_,last_);
75 value_type key_value(key_, value);
76 ref_.insert( key_value );
84 inline ref_const_ref_value_actor<T,ReferentT,insert_at_action>
90 return ref_const_ref_value_actor<
102 inline ref_const_ref_const_ref_actor<T,ReferentT,ValueT,insert_at_action>
105 ReferentT const& key_,
109 return ref_const_ref_const_ref_actor<
117 BOOST_SPIRIT_CLASSIC_NAMESPACE_END