]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/home/classic/actor/insert_at_actor.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / classic / actor / insert_at_actor.hpp
1 /*=============================================================================
2 Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
3 http://spirit.sourceforge.net/
4
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
10
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>
14
15 namespace boost { namespace spirit {
16
17 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
18
19 ///////////////////////////////////////////////////////////////////////////
20 // Summary:
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)
24 //
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) );
29 //
30 // Policy name:
31 // insert_at_action
32 //
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 );
36 //
37 // () operators: both
38 //
39 // See also ref_const_ref_value_actor and ref_const_ref_const_ref_actor
40 // for more details.
41 ///////////////////////////////////////////////////////////////////////////
42 struct insert_at_action
43 {
44 template<
45 typename T,
46 typename ReferentT,
47 typename ValueT
48 >
49 void act(
50 T& ref_,
51 ReferentT const& key_,
52 ValueT const& value_
53 ) const
54 {
55 typedef typename T::value_type value_type;
56 ref_.insert( value_type(key_, value_) );
57 }
58
59 template<
60 typename T,
61 typename ReferentT,
62 typename IteratorT
63 >
64 void act(
65 T& ref_,
66 ReferentT const& key_,
67 IteratorT const& first_,
68 IteratorT const& last_
69 ) const
70 {
71 typedef typename T::mapped_type mapped_type;
72 typedef typename T::value_type value_type;
73
74 mapped_type value(first_,last_);
75 value_type key_value(key_, value);
76 ref_.insert( key_value );
77 }
78 };
79
80 template<
81 typename T,
82 typename ReferentT
83 >
84 inline ref_const_ref_value_actor<T,ReferentT,insert_at_action>
85 insert_at_a(
86 T& ref_,
87 ReferentT const& key_
88 )
89 {
90 return ref_const_ref_value_actor<
91 T,
92 ReferentT,
93 insert_at_action
94 >(ref_,key_);
95 }
96
97 template<
98 typename T,
99 typename ReferentT,
100 typename ValueT
101 >
102 inline ref_const_ref_const_ref_actor<T,ReferentT,ValueT,insert_at_action>
103 insert_at_a(
104 T& ref_,
105 ReferentT const& key_,
106 ValueT const& value_
107 )
108 {
109 return ref_const_ref_const_ref_actor<
110 T,
111 ReferentT,
112 ValueT,
113 insert_at_action
114 >(ref_,key_,value_);
115 }
116
117 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
118
119 }}
120
121 #endif