Chris@16: /*============================================================================= Chris@16: Copyright (c) 2001-2011 Hartmut Kaiser Chris@16: Copyright (c) 2001-2011 Joel de Guzman Chris@16: Copyright (c) 2010 Bryce Lelbach Chris@16: Chris@16: Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: ==============================================================================*/ Chris@16: #if !defined(BOOST_SPIRIT_ATTRIBUTES_FWD_OCT_01_2009_0715AM) Chris@16: #define BOOST_SPIRIT_ATTRIBUTES_FWD_OCT_01_2009_0715AM Chris@16: Chris@16: #if defined(_MSC_VER) Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #if (defined(__GNUC__) && (__GNUC__ < 4)) || \ Chris@16: (defined(__APPLE__) && defined(__INTEL_COMPILER)) Chris@16: #include Chris@16: #endif Chris@16: #include Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: namespace boost { namespace spirit { namespace result_of Chris@16: { Chris@16: // forward declaration only Chris@16: template Chris@16: struct extract_from; Chris@16: Chris@16: template Chris@16: struct attribute_as; Chris@16: Chris@16: template Chris@16: struct pre_transform; Chris@16: Chris@16: template Chris@16: struct optional_value; Chris@16: Chris@16: template Chris@16: struct begin; Chris@16: Chris@16: template Chris@16: struct end; Chris@16: Chris@16: template Chris@16: struct deref; Chris@16: }}} Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: namespace boost { namespace spirit { namespace traits Chris@16: { Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Find out if T can be a strong substitute for Expected attribute Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct is_substitute; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Find out if T can be a weak substitute for Expected attribute Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct is_weak_substitute; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Determine if T is a proxy Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct is_proxy; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Retrieve the attribute type to use from the given type Chris@16: // Chris@16: // This is needed to extract the correct attribute type from proxy classes Chris@16: // as utilized in FUSION_ADAPT_ADT et. al. Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct attribute_type; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Retrieve the size of a fusion sequence (compile time) Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct sequence_size; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Retrieve the size of an attribute (runtime) Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct attribute_size; Chris@16: Chris@16: template Chris@16: typename attribute_size::type Chris@16: size(Attribute const& attr); Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Determines how we pass attributes to semantic actions. This Chris@16: // may be specialized. By default, all attributes are wrapped in Chris@16: // a fusion sequence, because the attribute has to be treated as being Chris@16: // a single value in any case (even if it actually already is a fusion Chris@16: // sequence in its own). Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct pass_attribute; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct optional_attribute; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Sometimes the user needs to transform the attribute types for certain Chris@16: // attributes. This template can be used as a customization point, where Chris@16: // the user is able specify specific transformation rules for any attribute Chris@16: // type. Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct transform_attribute; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Qi only Chris@16: template Chris@16: struct assign_to_attribute_from_iterators; Chris@16: Chris@16: template Chris@16: void assign_to(Iterator const& first, Iterator const& last, Attribute& attr); Chris@16: Chris@16: template Chris@16: void assign_to(Iterator const&, Iterator const&, unused_type); Chris@16: Chris@16: template Chris@16: struct assign_to_attribute_from_value; Chris@16: Chris@16: template Chris@16: struct assign_to_container_from_value; Chris@16: Chris@16: template Chris@16: void assign_to(T const& val, Attribute& attr); Chris@16: Chris@16: template Chris@16: void assign_to(T const&, unused_type); Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Karma only Chris@16: template Chris@16: struct extract_from_attribute; Chris@16: Chris@16: template Chris@16: struct extract_from_container; Chris@16: Chris@16: template Chris@16: typename spirit::result_of::extract_from::type Chris@16: extract_from(Attribute const& attr, Context& ctx Chris@16: #if (defined(__GNUC__) && (__GNUC__ < 4)) || \ Chris@16: (defined(__APPLE__) && defined(__INTEL_COMPILER)) Chris@16: , typename enable_if >::type* = NULL Chris@16: #endif Chris@16: ); Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Karma only Chris@16: template Chris@16: struct attribute_as; Chris@16: Chris@16: template Chris@16: typename spirit::result_of::attribute_as::type Chris@16: as(Attribute const& attr); Chris@16: Chris@16: template Chris@16: bool valid_as(Attribute const& attr); Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // return the type currently stored in the given variant Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct variant_which; Chris@16: Chris@16: template Chris@16: int which(T const& v); Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Determine, whether T is a variant like type Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct not_is_variant; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Determine, whether T is a variant like type Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct not_is_optional; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Clear data efficiently Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct clear_value; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////// Chris@16: // Determine the value type of the given container type Chris@16: /////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct container_value; Chris@16: Chris@16: template Chris@16: struct container_iterator; Chris@16: Chris@16: template Chris@16: struct is_container; Chris@16: Chris@16: template Chris@16: struct is_iterator_range; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct handles_container; Chris@16: Chris@16: template Chris@16: struct pass_through_container; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Qi only Chris@16: template Chris@16: struct push_back_container; Chris@16: Chris@16: template Chris@16: struct is_empty_container; Chris@16: Chris@16: template Chris@16: struct make_container_attribute; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////// Chris@16: // Determine the iterator type of the given container type Chris@16: // Karma only Chris@16: /////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct begin_container; Chris@16: Chris@16: template Chris@16: struct end_container; Chris@16: Chris@16: template Chris@16: struct deref_iterator; Chris@16: Chris@16: template Chris@16: struct next_iterator; Chris@16: Chris@16: template Chris@16: struct compare_iterators; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Print the given attribute of type T to the stream given as Out Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct print_attribute_debug; Chris@16: Chris@16: template Chris@16: void print_attribute(Out&, T const&); Chris@16: Chris@16: template Chris@16: void print_attribute(Out&, unused_type); Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct token_printer_debug; Chris@16: Chris@16: template Chris@16: void print_token(Out&, T const&); Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Access attributes from a karma symbol table Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct symbols_lookup; Chris@16: Chris@16: template Chris@16: struct symbols_value; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // transform attribute types exposed from compound operator components Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct alternative_attribute_transform; Chris@16: Chris@16: template Chris@16: struct sequence_attribute_transform; Chris@16: Chris@16: template Chris@16: struct permutation_attribute_transform; Chris@16: Chris@16: template Chris@16: struct sequential_or_attribute_transform; Chris@16: }}} Chris@16: Chris@16: #endif Chris@16: