]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_ERASE_ACTOR_HPP | |
9 | #define BOOST_SPIRIT_ACTOR_ERASE_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 | // A semantic action policy that calss the erase method. | |
22 | // (This doc uses convention available in actors.hpp) | |
23 | // | |
24 | // Actions (what it does): | |
25 | // ref.erase( value ); | |
26 | // ref.erase( T::key_type(first,last) ); | |
27 | // ref.erase( key_ref ); | |
28 | // | |
29 | // Policy name: | |
30 | // erase_action | |
31 | // | |
32 | // Policy holder, corresponding helper method: | |
33 | // ref_value_actor, erase_a( ref ); | |
34 | // ref_const_ref_actor, erase_a( ref, key_ref ); | |
35 | // | |
36 | // () operators: both | |
37 | // | |
38 | // See also ref_value_actor and ref_const_ref_actor for more details. | |
39 | /////////////////////////////////////////////////////////////////////////// | |
40 | struct erase_action | |
41 | { | |
42 | template< | |
43 | typename T, | |
44 | typename KeyT | |
45 | > | |
46 | void act(T& ref_, KeyT const& key_) const | |
47 | { | |
48 | ref_.erase(key_); | |
49 | } | |
50 | template< | |
51 | typename T, | |
52 | typename IteratorT | |
53 | > | |
54 | void act( | |
55 | T& ref_, | |
56 | IteratorT const& first_, | |
57 | IteratorT const& last_ | |
58 | ) const | |
59 | { | |
60 | typedef typename T::key_type key_type; | |
61 | key_type key(first_,last_); | |
62 | ||
63 | ref_.erase(key); | |
64 | } | |
65 | }; | |
66 | ||
67 | template<typename T> | |
68 | inline ref_value_actor<T,erase_action> erase_a(T& ref_) | |
69 | { | |
70 | return ref_value_actor<T,erase_action>(ref_); | |
71 | } | |
72 | ||
73 | template< | |
74 | typename T, | |
75 | typename KeyT | |
76 | > | |
77 | inline ref_const_ref_actor<T,KeyT,erase_action> erase_a( | |
78 | T& ref_, | |
79 | KeyT const& key_ | |
80 | ) | |
81 | { | |
82 | return ref_const_ref_actor<T,KeyT,erase_action>(ref_,key_); | |
83 | } | |
84 | ||
85 | BOOST_SPIRIT_CLASSIC_NAMESPACE_END | |
86 | ||
87 | }} | |
88 | ||
89 | #endif |