/*============================================================================= Copyright (c) 2001-2014 Joel de Guzman 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(SPIRIT_X3_DETAIL_ATTRIBUTES_APR_18_2010_0458PM) #define SPIRIT_X3_DETAIL_ATTRIBUTES_APR_18_2010_0458PM #include #include #include /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { namespace x3 { struct parser_id; template struct default_transform_attribute { typedef Transformed type; static Transformed pre(Exposed&) { return Transformed(); } static void post(Exposed& val, Transformed&& attr) { traits::move_to(std::forward(attr), val); } }; // handle case where no transformation is required as the types are the same template struct default_transform_attribute { typedef Attribute& type; static Attribute& pre(Attribute& val) { return val; } static void post(Attribute&, Attribute const&) {} }; // main specialization for x3 template struct transform_attribute : default_transform_attribute {}; // reference types need special handling template struct transform_attribute { typedef Attribute& type; static Attribute& pre(Attribute& val) { return val; } static void post(Attribute&, Attribute const&) {} }; // unused_type needs some special handling as well template <> struct transform_attribute { typedef unused_type type; static unused_type pre(unused_type) { return unused; } static void post(unused_type, unused_type) {} }; template <> struct transform_attribute : transform_attribute {}; template struct transform_attribute : transform_attribute {}; template struct transform_attribute : transform_attribute {}; template struct transform_attribute : transform_attribute {}; template struct transform_attribute : transform_attribute {}; }}} /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { namespace x3 { namespace traits { template struct transform_attribute : x3::transform_attribute {}; template struct transform_attribute : transform_attribute {}; template struct transform_attribute : x3::transform_attribute {}; /////////////////////////////////////////////////////////////////////////// template void post_transform(Exposed& dest, Transformed&& attr) { return transform_attribute ::post(dest, std::forward(attr)); } }}}} #endif