Chris@16: // Copyright (c) 2001-2011 Hartmut Kaiser Chris@16: // Copyright (c) 2001-2011 Joel de Guzman 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(SPIRIT_KARMA_DETAIL_ATTRIBUTES_APR_18_2010_0453PM) Chris@16: #define SPIRIT_KARMA_DETAIL_ATTRIBUTES_APR_18_2010_0453PM Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: namespace boost { namespace spirit { namespace karma Chris@16: { Chris@16: template Chris@16: struct transform_attribute Chris@16: { Chris@16: typedef Transformed type; Chris@16: static Transformed pre(Exposed& val) Chris@16: { Chris@16: return Transformed(traits::extract_from(val, unused)); Chris@16: } Chris@16: // Karma only, no post() and no fail() required Chris@16: }; Chris@16: Chris@16: template Chris@16: struct transform_attribute const, Transformed Chris@16: , typename disable_if, Transformed> >::type> Chris@16: { Chris@16: typedef Transformed const& type; Chris@16: static Transformed const& pre(boost::optional const& val) Chris@16: { Chris@16: return boost::get(val); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct transform_attribute Chris@16: { Chris@16: typedef Attribute const& type; Chris@16: static Attribute const& pre(Attribute const& val) { return val; } Chris@16: // Karma only, no post() and no fail() required Chris@16: }; Chris@16: Chris@16: // reference types need special handling Chris@16: template Chris@16: struct transform_attribute Chris@16: : transform_attribute Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct transform_attribute Chris@16: : transform_attribute Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct transform_attribute Chris@16: : transform_attribute Chris@16: {}; Chris@16: Chris@16: // unused_type needs some special handling as well Chris@16: template <> Chris@16: struct transform_attribute Chris@16: { Chris@16: typedef unused_type type; Chris@16: static unused_type pre(unused_type) { return unused; } Chris@16: }; Chris@16: Chris@16: template <> Chris@16: struct transform_attribute Chris@16: : transform_attribute Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct transform_attribute Chris@16: : transform_attribute Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct transform_attribute Chris@16: : transform_attribute Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct transform_attribute Chris@16: : transform_attribute Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct transform_attribute Chris@16: : transform_attribute Chris@16: {}; Chris@16: }}} Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: namespace boost { namespace spirit { namespace traits Chris@16: { Chris@16: template Chris@16: struct transform_attribute Chris@16: : karma::transform_attribute Chris@16: {}; Chris@16: }}} Chris@16: Chris@16: #endif Chris@16: Chris@16: