1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is
* Fridrich Strba <fridrich.strba@bluewin.ch>
* Thorsten Behrens <tbehrens@novell.com>
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#ifndef INCLUDED_SPIRIT_SUPPLEMENTS_HXX
#define INCLUDED_SPIRIT_SUPPLEMENTS_HXX
# ifndef USE_MODERN_SPIRIT
# include <boost/spirit.hpp>
namespace boost { namespace spirit
{
template <>
class assign_actor< std::pair<const char*,const char*> >
{
public:
explicit assign_actor(std::pair<const char*,const char*>& ref_)
: ref(ref_) {}
template <typename T2>
void operator()(T2 const& val) const
{ ref = val; }
template <typename IteratorT>
void operator()(IteratorT const& f, IteratorT const& l) const
{
ref.first = f, ref.second = l;
}
private:
std::pair<const char*,const char*>& ref;
};
template<typename Target, typename Value> struct assigner
{
assigner( Target& rTarget, Value aValue ) :
mrTarget(rTarget), maValue(aValue)
{}
void assign() const { mrTarget=maValue; }
void operator()() const { assign(); }
template<typename T1> void operator()(T1) const { assign(); }
template<typename T1,typename T2> void operator()(T1,T2) const { assign(); }
template<typename T1,typename T2,typename T3> void operator()(T1,T2,T3) const { assign(); }
Target& mrTarget;
const Value maValue;
};
template<typename Target, typename Value> inline assigner<Target,Value>
assign_a( Target& rTarget, Value aValue )
{
return assigner<Target,Value>(rTarget,aValue);
}
template <typename Target> inline assign_actor<Target>
assign_a(Target& rTarget)
{
return assign_actor<Target>(rTarget);
}
template<typename Target, typename Value> struct back_pusher
{
back_pusher( Target& rTarget, const Value& rValue ) :
mrTarget(rTarget), mrValue(rValue)
{}
void push_back() const { mrTarget.push_back(mrValue); }
void operator()() const { push_back(); }
template<typename T1> void operator()(T1) const { push_back(); }
template<typename T1,typename T2> void operator()(T1,T2) const { push_back(); }
template<typename T1,typename T2,typename T3> void operator()(T1,T2,T3) const { push_back(); }
Target& mrTarget;
const Value& mrValue;
};
template<typename Target, typename Value> inline back_pusher<Target,Value>
push_back_a( Target& rTarget, const Value& rValue )
{
return back_pusher<Target,Value>(rTarget,rValue);
}
template<typename Target> struct value_back_pusher
{
explicit value_back_pusher( Target& rTarget ) :
mrTarget(rTarget)
{}
template<typename T1> void operator()(T1 val) const { mrTarget.push_back(val); }
Target& mrTarget;
};
template<typename Target> inline value_back_pusher<Target>
push_back_a( Target& rTarget )
{
return value_back_pusher<Target>(rTarget);
}
} }
# endif
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|