]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/home/classic/actor/push_back_actor.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / classic / actor / push_back_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_PUSH_BACK_ACTOR_HPP
9 #define BOOST_SPIRIT_ACTOR_PUSH_BACK_ACTOR_HPP
10
11 #include <boost/spirit/home/classic/namespace.hpp>
12 #include <boost/spirit/home/classic/actor/ref_value_actor.hpp>
13 #include <boost/spirit/home/classic/actor/ref_const_ref_actor.hpp>
14
15 namespace boost { namespace spirit {
16
17 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
18
19 ///////////////////////////////////////////////////////////////////////////
20 // Summary:
21 //
22 // A semantic action policy that appends a value to the back of a
23 // container.
24 // (This doc uses convention available in actors.hpp)
25 //
26 // Actions (what it does and what ref, value_ref must support):
27 // ref.push_back( value );
28 // ref.push_back( T::value_type(first,last) );
29 // ref.push_back( value_ref );
30 //
31 // Policy name:
32 // push_back_action
33 //
34 // Policy holder, corresponding helper method:
35 // ref_value_actor, push_back_a( ref );
36 // ref_const_ref_actor, push_back_a( ref, value_ref );
37 //
38 // () operators: both
39 //
40 // See also ref_value_actor and ref_const_ref_actor for more details.
41 ///////////////////////////////////////////////////////////////////////////
42 struct push_back_action
43 {
44 template<
45 typename T,
46 typename ValueT
47 >
48 void act(T& ref_, ValueT const& value_) const
49 {
50 ref_.push_back( value_ );
51 }
52 template<
53 typename T,
54 typename IteratorT
55 >
56 void act(
57 T& ref_,
58 IteratorT const& first_,
59 IteratorT const& last_
60 ) const
61 {
62 typedef typename T::value_type value_type;
63 value_type value(first_,last_);
64
65 ref_.push_back( value );
66 }
67 };
68
69 // Deprecated interface. Use push_back_a
70 template<typename T>
71 inline ref_value_actor<T,push_back_action>
72 append(T& ref_)
73 {
74 return ref_value_actor<T,push_back_action>(ref_);
75 }
76
77 template<typename T>
78 inline ref_value_actor<T,push_back_action>
79 push_back_a(T& ref_)
80 {
81 return ref_value_actor<T,push_back_action>(ref_);
82 }
83
84 template<
85 typename T,
86 typename ValueT
87 >
88 inline ref_const_ref_actor<T,ValueT,push_back_action>
89 push_back_a(
90 T& ref_,
91 ValueT const& value_
92 )
93 {
94 return ref_const_ref_actor<T,ValueT,push_back_action>(ref_,value_);
95 }
96
97 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
98
99 }}
100
101 #endif