// Copyright (c) 2001-2011 Hartmut Kaiser // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #if !defined(BOOST_SPIRIT_ADAPT_ADT_ATTRIBUTES_SEP_15_2010_1219PM) #define BOOST_SPIRIT_ADAPT_ADT_ATTRIBUTES_SEP_15_2010_1219PM #if defined(_MSC_VER) #pragma once #endif #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// // customization points allowing to use adapted classes with spirit namespace boost { namespace spirit { namespace traits { /////////////////////////////////////////////////////////////////////////// template struct not_is_variant< fusion::extension::adt_attribute_proxy, Domain> : not_is_variant< typename fusion::extension::adt_attribute_proxy::type , Domain> {}; template struct not_is_optional< fusion::extension::adt_attribute_proxy, Domain> : not_is_optional< typename fusion::extension::adt_attribute_proxy::type , Domain> {}; /////////////////////////////////////////////////////////////////////////// template struct is_container > : is_container< typename fusion::extension::adt_attribute_proxy::type > {}; template struct container_value > : container_value< typename remove_reference< typename fusion::extension::adt_attribute_proxy< T, N, Const >::type >::type > {}; template struct container_value< fusion::extension::adt_attribute_proxy const> : container_value< typename add_const< typename remove_reference< typename fusion::extension::adt_attribute_proxy< T, N, Const >::type >::type >::type > {}; template struct push_back_container< fusion::extension::adt_attribute_proxy , Val , typename enable_if::type > >::type> { static bool call( fusion::extension::adt_attribute_proxy& p , Val const& val) { typedef typename fusion::extension::adt_attribute_proxy::type type; return push_back(type(p), val); } }; template struct container_iterator< fusion::extension::adt_attribute_proxy > : container_iterator< typename remove_reference< typename fusion::extension::adt_attribute_proxy< T, N, Const >::type >::type > {}; template struct container_iterator< fusion::extension::adt_attribute_proxy const> : container_iterator< typename add_const< typename remove_reference< typename fusion::extension::adt_attribute_proxy< T, N, Const >::type >::type >::type > {}; template struct begin_container > { typedef typename remove_reference< typename fusion::extension::adt_attribute_proxy::type >::type container_type; static typename container_iterator::type call(fusion::extension::adt_attribute_proxy& c) { return c.get().begin(); } }; template struct begin_container const> { typedef typename add_const< typename remove_reference< typename fusion::extension::adt_attribute_proxy::type >::type >::type container_type; static typename container_iterator::type call(fusion::extension::adt_attribute_proxy const& c) { return c.get().begin(); } }; template struct end_container > { typedef typename remove_reference< typename fusion::extension::adt_attribute_proxy::type >::type container_type; static typename container_iterator::type call(fusion::extension::adt_attribute_proxy& c) { return c.get().end(); } }; template struct end_container const> { typedef typename add_const< typename remove_reference< typename fusion::extension::adt_attribute_proxy::type >::type >::type container_type; static typename container_iterator::type call(fusion::extension::adt_attribute_proxy const& c) { return c.get().end(); } }; /////////////////////////////////////////////////////////////////////////// template struct assign_to_attribute_from_value< fusion::extension::adt_attribute_proxy , Val> { static void call(Val const& val , fusion::extension::adt_attribute_proxy& attr) { attr = val; } }; template struct extract_from_attribute< fusion::extension::adt_attribute_proxy, Exposed> { typedef typename remove_const< typename remove_reference< typename fusion::extension::adt_attribute_proxy::type >::type >::type embedded_type; typedef typename spirit::result_of::extract_from::type type; template static type call(fusion::extension::adt_attribute_proxy const& val, Context& ctx) { return extract_from(val.get(), ctx); } }; /////////////////////////////////////////////////////////////////////////// template struct attribute_type > : fusion::extension::adt_attribute_proxy {}; /////////////////////////////////////////////////////////////////////////// template struct optional_attribute< fusion::extension::adt_attribute_proxy > { typedef typename result_of::optional_value< typename remove_reference< typename fusion::extension::adt_attribute_proxy::type >::type >::type type; static type call(fusion::extension::adt_attribute_proxy const& val) { return optional_value(val.get()); } static bool is_valid(fusion::extension::adt_attribute_proxy const& val) { return has_optional_value(val.get()); } }; /////////////////////////////////////////////////////////////////////////// template struct transform_attribute< fusion::extension::adt_attribute_proxy , Attribute , Domain , typename disable_if::type > >::type> { typedef Attribute type; static Attribute pre(fusion::extension::adt_attribute_proxy& val) { return val; } static void post( fusion::extension::adt_attribute_proxy& val , Attribute const& attr) { val = attr; } static void fail(fusion::extension::adt_attribute_proxy&) { } }; template < typename T, int N, bool Const, typename Attribute, typename Domain> struct transform_attribute< fusion::extension::adt_attribute_proxy , Attribute , Domain , typename enable_if::type > >::type> { typedef Attribute& type; static Attribute& pre(fusion::extension::adt_attribute_proxy& val) { return val; } static void post( fusion::extension::adt_attribute_proxy& , Attribute const&) { } static void fail(fusion::extension::adt_attribute_proxy&) { } }; template struct clear_value > { static void call( fusion::extension::adt_attribute_proxy& val) { typedef typename fusion::extension::adt_attribute_proxy::type type; clear(type(val)); } }; template struct attribute_size > { typedef typename remove_const< typename remove_reference< typename fusion::extension::adt_attribute_proxy::type >::type >::type embedded_type; typedef typename attribute_size::type type; static type call(fusion::extension::adt_attribute_proxy const& val) { return attribute_size::call(val.get()); } }; /////////////////////////////////////////////////////////////////////////// // customization point specializations for numeric generators template struct absolute_value > { typedef typename fusion::extension::adt_attribute_proxy::type type; static type call (fusion::extension::adt_attribute_proxy const& val) { return get_absolute_value(val.get()); } }; template struct is_negative > { static bool call(fusion::extension::adt_attribute_proxy const& val) { return test_negative(val.get()); } }; template struct is_zero > { static bool call(fusion::extension::adt_attribute_proxy const& val) { return test_zero(val.get()); } }; template struct is_nan > { static bool call(fusion::extension::adt_attribute_proxy const& val) { return test_nan(val.get()); } }; template struct is_infinite > { static bool call(fusion::extension::adt_attribute_proxy const& val) { return test_infinite(val.get()); } }; }}} /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { namespace result_of { template struct optional_value > : result_of::optional_value< typename remove_const< typename remove_reference< typename fusion::extension::adt_attribute_proxy::type >::type >::type> {}; }}} #endif