Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2001-2011 Hartmut Kaiser
|
Chris@16
|
3 Copyright (c) 2001-2011 Joel de Guzman
|
Chris@16
|
4 Copyright (c) 2010 Bryce Lelbach
|
Chris@16
|
5
|
Chris@16
|
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8 ==============================================================================*/
|
Chris@16
|
9 #if !defined(BOOST_SPIRIT_ATTRIBUTES_FWD_OCT_01_2009_0715AM)
|
Chris@16
|
10 #define BOOST_SPIRIT_ATTRIBUTES_FWD_OCT_01_2009_0715AM
|
Chris@16
|
11
|
Chris@16
|
12 #if defined(_MSC_VER)
|
Chris@16
|
13 #pragma once
|
Chris@16
|
14 #endif
|
Chris@16
|
15
|
Chris@16
|
16 #include <boost/config.hpp>
|
Chris@16
|
17 #if (defined(__GNUC__) && (__GNUC__ < 4)) || \
|
Chris@16
|
18 (defined(__APPLE__) && defined(__INTEL_COMPILER))
|
Chris@16
|
19 #include <boost/utility/enable_if.hpp>
|
Chris@16
|
20 #endif
|
Chris@16
|
21 #include <boost/spirit/home/support/unused.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
24 namespace boost { namespace spirit { namespace result_of
|
Chris@16
|
25 {
|
Chris@16
|
26 // forward declaration only
|
Chris@16
|
27 template <typename Exposed, typename Attribute>
|
Chris@16
|
28 struct extract_from;
|
Chris@16
|
29
|
Chris@16
|
30 template <typename T, typename Attribute>
|
Chris@16
|
31 struct attribute_as;
|
Chris@16
|
32
|
Chris@16
|
33 template <typename Exposed, typename Transformed, typename Domain>
|
Chris@16
|
34 struct pre_transform;
|
Chris@16
|
35
|
Chris@16
|
36 template <typename T>
|
Chris@16
|
37 struct optional_value;
|
Chris@16
|
38
|
Chris@16
|
39 template <typename Container>
|
Chris@16
|
40 struct begin;
|
Chris@16
|
41
|
Chris@16
|
42 template <typename Container>
|
Chris@16
|
43 struct end;
|
Chris@16
|
44
|
Chris@16
|
45 template <typename Iterator>
|
Chris@16
|
46 struct deref;
|
Chris@16
|
47 }}}
|
Chris@16
|
48
|
Chris@16
|
49 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
50 namespace boost { namespace spirit { namespace traits
|
Chris@16
|
51 {
|
Chris@16
|
52 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
53 // Find out if T can be a strong substitute for Expected attribute
|
Chris@16
|
54 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
55 template <typename T, typename Expected, typename Enable = void>
|
Chris@16
|
56 struct is_substitute;
|
Chris@16
|
57
|
Chris@16
|
58 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
59 // Find out if T can be a weak substitute for Expected attribute
|
Chris@16
|
60 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
61 template <typename T, typename Expected, typename Enable = void>
|
Chris@16
|
62 struct is_weak_substitute;
|
Chris@16
|
63
|
Chris@16
|
64 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
65 // Determine if T is a proxy
|
Chris@16
|
66 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
67 template <typename T, typename Enable = void>
|
Chris@16
|
68 struct is_proxy;
|
Chris@16
|
69
|
Chris@16
|
70 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
71 // Retrieve the attribute type to use from the given type
|
Chris@16
|
72 //
|
Chris@16
|
73 // This is needed to extract the correct attribute type from proxy classes
|
Chris@16
|
74 // as utilized in FUSION_ADAPT_ADT et. al.
|
Chris@16
|
75 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
76 template <typename Attribute, typename Enable = void>
|
Chris@16
|
77 struct attribute_type;
|
Chris@16
|
78
|
Chris@16
|
79 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
80 // Retrieve the size of a fusion sequence (compile time)
|
Chris@16
|
81 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
82 template <typename T>
|
Chris@16
|
83 struct sequence_size;
|
Chris@16
|
84
|
Chris@16
|
85 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
86 // Retrieve the size of an attribute (runtime)
|
Chris@16
|
87 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
88 template <typename Attribute, typename Enable = void>
|
Chris@16
|
89 struct attribute_size;
|
Chris@16
|
90
|
Chris@16
|
91 template <typename Attribute>
|
Chris@16
|
92 typename attribute_size<Attribute>::type
|
Chris@16
|
93 size(Attribute const& attr);
|
Chris@16
|
94
|
Chris@16
|
95 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
96 // Determines how we pass attributes to semantic actions. This
|
Chris@16
|
97 // may be specialized. By default, all attributes are wrapped in
|
Chris@16
|
98 // a fusion sequence, because the attribute has to be treated as being
|
Chris@16
|
99 // a single value in any case (even if it actually already is a fusion
|
Chris@16
|
100 // sequence in its own).
|
Chris@16
|
101 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
102 template <typename Component, typename Attribute, typename Enable = void>
|
Chris@16
|
103 struct pass_attribute;
|
Chris@16
|
104
|
Chris@16
|
105 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
106 template <typename T, typename Enable = void>
|
Chris@16
|
107 struct optional_attribute;
|
Chris@16
|
108
|
Chris@16
|
109 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
110 // Sometimes the user needs to transform the attribute types for certain
|
Chris@16
|
111 // attributes. This template can be used as a customization point, where
|
Chris@16
|
112 // the user is able specify specific transformation rules for any attribute
|
Chris@16
|
113 // type.
|
Chris@16
|
114 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
115 template <typename Exposed, typename Transformed, typename Domain
|
Chris@16
|
116 , typename Enable = void>
|
Chris@16
|
117 struct transform_attribute;
|
Chris@16
|
118
|
Chris@16
|
119 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
120 // Qi only
|
Chris@16
|
121 template <typename Attribute, typename Iterator, typename Enable = void>
|
Chris@16
|
122 struct assign_to_attribute_from_iterators;
|
Chris@16
|
123
|
Chris@16
|
124 template <typename Iterator, typename Attribute>
|
Chris@16
|
125 void assign_to(Iterator const& first, Iterator const& last, Attribute& attr);
|
Chris@16
|
126
|
Chris@16
|
127 template <typename Iterator>
|
Chris@16
|
128 void assign_to(Iterator const&, Iterator const&, unused_type);
|
Chris@16
|
129
|
Chris@16
|
130 template <typename Attribute, typename T, typename Enable = void>
|
Chris@16
|
131 struct assign_to_attribute_from_value;
|
Chris@16
|
132
|
Chris@16
|
133 template <typename Attribute, typename T, typename Enable = void>
|
Chris@16
|
134 struct assign_to_container_from_value;
|
Chris@16
|
135
|
Chris@16
|
136 template <typename T, typename Attribute>
|
Chris@16
|
137 void assign_to(T const& val, Attribute& attr);
|
Chris@16
|
138
|
Chris@16
|
139 template <typename T>
|
Chris@16
|
140 void assign_to(T const&, unused_type);
|
Chris@16
|
141
|
Chris@16
|
142 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
143 // Karma only
|
Chris@16
|
144 template <typename Attribute, typename Exposed, typename Enable = void>
|
Chris@16
|
145 struct extract_from_attribute;
|
Chris@16
|
146
|
Chris@16
|
147 template <typename Attribute, typename Exposed, typename Enable = void>
|
Chris@16
|
148 struct extract_from_container;
|
Chris@16
|
149
|
Chris@16
|
150 template <typename Exposed, typename Attribute, typename Context>
|
Chris@16
|
151 typename spirit::result_of::extract_from<Exposed, Attribute>::type
|
Chris@16
|
152 extract_from(Attribute const& attr, Context& ctx
|
Chris@16
|
153 #if (defined(__GNUC__) && (__GNUC__ < 4)) || \
|
Chris@16
|
154 (defined(__APPLE__) && defined(__INTEL_COMPILER))
|
Chris@16
|
155 , typename enable_if<traits::not_is_unused<Attribute> >::type* = NULL
|
Chris@16
|
156 #endif
|
Chris@16
|
157 );
|
Chris@16
|
158
|
Chris@16
|
159 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
160 // Karma only
|
Chris@16
|
161 template <typename T, typename Attribute, typename Enable = void>
|
Chris@16
|
162 struct attribute_as;
|
Chris@16
|
163
|
Chris@16
|
164 template <typename T, typename Attribute>
|
Chris@16
|
165 typename spirit::result_of::attribute_as<T, Attribute>::type
|
Chris@16
|
166 as(Attribute const& attr);
|
Chris@16
|
167
|
Chris@16
|
168 template <typename T, typename Attribute>
|
Chris@16
|
169 bool valid_as(Attribute const& attr);
|
Chris@16
|
170
|
Chris@16
|
171 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
172 // return the type currently stored in the given variant
|
Chris@16
|
173 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
174 template <typename T, typename Enable = void>
|
Chris@16
|
175 struct variant_which;
|
Chris@16
|
176
|
Chris@16
|
177 template <typename T>
|
Chris@16
|
178 int which(T const& v);
|
Chris@16
|
179
|
Chris@16
|
180 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
181 // Determine, whether T is a variant like type
|
Chris@16
|
182 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
183 template <typename T, typename Domain = unused_type, typename Enable = void>
|
Chris@16
|
184 struct not_is_variant;
|
Chris@16
|
185
|
Chris@16
|
186 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
187 // Determine, whether T is a variant like type
|
Chris@16
|
188 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
189 template <typename T, typename Domain = unused_type, typename Enable = void>
|
Chris@16
|
190 struct not_is_optional;
|
Chris@16
|
191
|
Chris@16
|
192 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
193 // Clear data efficiently
|
Chris@16
|
194 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
195 template <typename T, typename Enable = void>
|
Chris@16
|
196 struct clear_value;
|
Chris@16
|
197
|
Chris@16
|
198 ///////////////////////////////////////////////////////////////////////
|
Chris@16
|
199 // Determine the value type of the given container type
|
Chris@16
|
200 ///////////////////////////////////////////////////////////////////////
|
Chris@16
|
201 template <typename Container, typename Enable = void>
|
Chris@16
|
202 struct container_value;
|
Chris@16
|
203
|
Chris@16
|
204 template <typename Container, typename Enable = void>
|
Chris@16
|
205 struct container_iterator;
|
Chris@16
|
206
|
Chris@16
|
207 template <typename T, typename Enable = void>
|
Chris@16
|
208 struct is_container;
|
Chris@16
|
209
|
Chris@16
|
210 template <typename T, typename Enable = void>
|
Chris@16
|
211 struct is_iterator_range;
|
Chris@16
|
212
|
Chris@16
|
213 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
214 template <typename T, typename Attribute, typename Context = unused_type
|
Chris@16
|
215 , typename Iterator = unused_type, typename Enable = void>
|
Chris@16
|
216 struct handles_container;
|
Chris@16
|
217
|
Chris@16
|
218 template <typename Container, typename ValueType, typename Attribute
|
Chris@16
|
219 , typename Sequence, typename Domain, typename Enable = void>
|
Chris@16
|
220 struct pass_through_container;
|
Chris@16
|
221
|
Chris@16
|
222 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
223 // Qi only
|
Chris@16
|
224 template <typename Container, typename T, typename Enable = void>
|
Chris@16
|
225 struct push_back_container;
|
Chris@16
|
226
|
Chris@16
|
227 template <typename Container, typename Enable = void>
|
Chris@16
|
228 struct is_empty_container;
|
Chris@16
|
229
|
Chris@16
|
230 template <typename Container, typename Enable = void>
|
Chris@16
|
231 struct make_container_attribute;
|
Chris@16
|
232
|
Chris@16
|
233 ///////////////////////////////////////////////////////////////////////
|
Chris@16
|
234 // Determine the iterator type of the given container type
|
Chris@16
|
235 // Karma only
|
Chris@16
|
236 ///////////////////////////////////////////////////////////////////////
|
Chris@16
|
237 template <typename Container, typename Enable = void>
|
Chris@16
|
238 struct begin_container;
|
Chris@16
|
239
|
Chris@16
|
240 template <typename Container, typename Enable = void>
|
Chris@16
|
241 struct end_container;
|
Chris@16
|
242
|
Chris@16
|
243 template <typename Iterator, typename Enable = void>
|
Chris@16
|
244 struct deref_iterator;
|
Chris@16
|
245
|
Chris@16
|
246 template <typename Iterator, typename Enable = void>
|
Chris@16
|
247 struct next_iterator;
|
Chris@16
|
248
|
Chris@16
|
249 template <typename Iterator, typename Enable = void>
|
Chris@16
|
250 struct compare_iterators;
|
Chris@16
|
251
|
Chris@16
|
252 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
253 // Print the given attribute of type T to the stream given as Out
|
Chris@16
|
254 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
255 template <typename Out, typename T, typename Enable = void>
|
Chris@16
|
256 struct print_attribute_debug;
|
Chris@16
|
257
|
Chris@16
|
258 template <typename Out, typename T>
|
Chris@16
|
259 void print_attribute(Out&, T const&);
|
Chris@16
|
260
|
Chris@16
|
261 template <typename Out>
|
Chris@16
|
262 void print_attribute(Out&, unused_type);
|
Chris@16
|
263
|
Chris@16
|
264 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
265 template <typename Char, typename Enable = void>
|
Chris@16
|
266 struct token_printer_debug;
|
Chris@16
|
267
|
Chris@16
|
268 template<typename Out, typename T>
|
Chris@16
|
269 void print_token(Out&, T const&);
|
Chris@16
|
270
|
Chris@16
|
271 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
272 // Access attributes from a karma symbol table
|
Chris@16
|
273 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
274 template <typename T, typename Attribute, typename Enable = void>
|
Chris@16
|
275 struct symbols_lookup;
|
Chris@16
|
276
|
Chris@16
|
277 template <typename Attribute, typename T, typename Enable = void>
|
Chris@16
|
278 struct symbols_value;
|
Chris@16
|
279
|
Chris@16
|
280 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
281 // transform attribute types exposed from compound operator components
|
Chris@16
|
282 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
283 template <typename Attribute, typename Domain>
|
Chris@16
|
284 struct alternative_attribute_transform;
|
Chris@16
|
285
|
Chris@16
|
286 template <typename Attribute, typename Domain>
|
Chris@16
|
287 struct sequence_attribute_transform;
|
Chris@16
|
288
|
Chris@16
|
289 template <typename Attribute, typename Domain>
|
Chris@16
|
290 struct permutation_attribute_transform;
|
Chris@16
|
291
|
Chris@16
|
292 template <typename Attribute, typename Domain>
|
Chris@16
|
293 struct sequential_or_attribute_transform;
|
Chris@16
|
294 }}}
|
Chris@16
|
295
|
Chris@16
|
296 #endif
|
Chris@16
|
297
|