source: NonGTP/Boost/boost/spirit/actor/assign_key_actor.hpp @ 857

Revision 857, 2.3 KB checked in by igarcia, 18 years ago (diff)
Line 
1/*=============================================================================
2    Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
3    http://spirit.sourceforge.net/
4
5    Use, modification and distribution is subject to the Boost Software
6    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7    http://www.boost.org/LICENSE_1_0.txt)
8=============================================================================*/
9#ifndef BOOST_SPIRIT_ACTOR_ASSIGN_KEY_ACTOR_HPP
10#define BOOST_SPIRIT_ACTOR_ASSIGN_KEY_ACTOR_HPP
11
12#include <boost/spirit/actor/ref_const_ref_value_actor.hpp>
13#include <boost/spirit/actor/ref_const_ref_const_ref_a.hpp>
14
15namespace boost { namespace spirit {
16
17    struct assign_key_action
18    {
19        template<
20            typename T,
21            typename ValueT,
22            typename KeyT
23        >
24        void act(T& ref_, ValueT const& value_, KeyT const& key_) const
25        {
26            ref_[ key_ ] = value_;
27        }
28
29        template<
30            typename T,
31            typename ValueT,
32            typename IteratorT
33        >
34        void act(
35            T& ref_,
36            ValueT const& value_,
37            IteratorT const& first_,
38            IteratorT const& last_
39            ) const
40        {
41            typedef typename T::key_type key_type;
42            key_type key(first_,last_);
43
44            ref_[key] = value_;
45        }
46    };
47
48    template<
49        typename T,
50        typename ValueT
51    >
52    inline ref_const_ref_value_actor<T,ValueT,assign_key_action>
53        assign_key_a(T& ref_, ValueT const& value_)
54    {
55        return ref_const_ref_value_actor<T,ValueT,assign_key_action>(
56            ref_,
57            value_
58            );
59    }
60
61    template<
62        typename T,
63        typename ValueT,
64        typename KeyT
65    >
66    inline ref_const_ref_const_ref_actor<
67        T,
68        ValueT,
69        KeyT,
70        assign_key_action
71    >
72        assign_key_a(
73            T& ref_,
74            ValueT const& value_,
75            KeyT const& key_
76    )
77    {
78        return ref_const_ref_const_ref_actor<
79            T,
80            ValueT,
81            KeyT,
82            assign_key_action
83        >(
84            ref_,
85            value_,
86            key_
87            );
88    }
89
90}}
91
92#endif
Note: See TracBrowser for help on using the repository browser.