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