1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
6 * Fridrich Strba <fridrich.strba@bluewin.ch>
7 * Thorsten Behrens <tbehrens@novell.com>
9 * Copyright (C) 2008, Novell Inc.
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
14 ************************************************************************/
16 #ifndef INCLUDED_SPIRIT_SUPPLEMENTS_HXX
17 #define INCLUDED_SPIRIT_SUPPLEMENTS_HXX
19 # ifndef USE_MODERN_SPIRIT
20 # include <boost/spirit.hpp>
22 namespace boost
{ namespace spirit
25 class assign_actor
< std::pair
<const char*,const char*> >
28 explicit assign_actor(std::pair
<const char*,const char*>& ref_
)
31 template <typename T2
>
32 void operator()(T2
const& val
) const
35 template <typename IteratorT
>
36 void operator()(IteratorT
const& f
, IteratorT
const& l
) const
38 ref
.first
= f
, ref
.second
= l
;
42 std::pair
<const char*,const char*>& ref
;
45 template<typename Target
, typename Value
> struct assigner
47 assigner( Target
& rTarget
, Value aValue
) :
48 mrTarget(rTarget
), maValue(aValue
)
51 void assign() const { mrTarget
=maValue
; }
53 void operator()() const { assign(); }
54 template<typename T1
> void operator()(T1
) const { assign(); }
55 template<typename T1
,typename T2
> void operator()(T1
,T2
) const { assign(); }
56 template<typename T1
,typename T2
,typename T3
> void operator()(T1
,T2
,T3
) const { assign(); }
62 template<typename Target
, typename Value
> inline assigner
<Target
,Value
>
63 assign_a( Target
& rTarget
, Value aValue
)
65 return assigner
<Target
,Value
>(rTarget
,aValue
);
68 template <typename Target
> inline assign_actor
<Target
>
69 assign_a(Target
& rTarget
)
71 return assign_actor
<Target
>(rTarget
);
74 template<typename Target
, typename Value
> struct back_pusher
76 back_pusher( Target
& rTarget
, const Value
& rValue
) :
77 mrTarget(rTarget
), mrValue(rValue
)
80 void push_back() const { mrTarget
.push_back(mrValue
); }
82 void operator()() const { push_back(); }
83 template<typename T1
> void operator()(T1
) const { push_back(); }
84 template<typename T1
,typename T2
> void operator()(T1
,T2
) const { push_back(); }
85 template<typename T1
,typename T2
,typename T3
> void operator()(T1
,T2
,T3
) const { push_back(); }
91 template<typename Target
, typename Value
> inline back_pusher
<Target
,Value
>
92 push_back_a( Target
& rTarget
, const Value
& rValue
)
94 return back_pusher
<Target
,Value
>(rTarget
,rValue
);
97 template<typename Target
> struct value_back_pusher
99 explicit value_back_pusher( Target
& rTarget
) :
102 template<typename T1
> void operator()(T1 val
) const { mrTarget
.push_back(val
); }
107 template<typename Target
> inline value_back_pusher
<Target
>
108 push_back_a( Target
& rTarget
)
110 return value_back_pusher
<Target
>(rTarget
);