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