Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/spirit/home/karma/detail/attributes.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //  Copyright (c) 2001-2011 Hartmut Kaiser
0002 //  Copyright (c) 2001-2011 Joel de Guzman
0003 //
0004 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_SPIRIT_KARMA_DETAIL_ATTRIBUTES_HPP
0008 #define BOOST_SPIRIT_KARMA_DETAIL_ATTRIBUTES_HPP
0009 
0010 #include <boost/spirit/home/karma/domain.hpp>
0011 #include <boost/spirit/home/support/attributes_fwd.hpp>
0012 #include <boost/spirit/home/support/attributes.hpp>
0013 
0014 ///////////////////////////////////////////////////////////////////////////////
0015 namespace boost { namespace spirit { namespace karma
0016 {
0017     template <typename Exposed, typename Transformed, typename Enable = void>
0018     struct transform_attribute
0019     {
0020         typedef Transformed type;
0021         static Transformed pre(Exposed& val) 
0022         { 
0023             return Transformed(traits::extract_from<Transformed>(val, unused));
0024         }
0025         // Karma only, no post() and no fail() required
0026     };
0027 
0028     template <typename Exposed, typename Transformed>
0029     struct transform_attribute<boost::optional<Exposed> const, Transformed
0030       , typename disable_if<is_same<boost::optional<Exposed>, Transformed> >::type>
0031     {
0032         typedef Transformed const& type;
0033         static Transformed const& pre(boost::optional<Exposed> const& val)
0034         {
0035             return boost::get<Transformed>(val);
0036         }
0037     };
0038 
0039     template <typename Attribute>
0040     struct transform_attribute<Attribute const, Attribute>
0041     {
0042         typedef Attribute const& type;
0043         static Attribute const& pre(Attribute const& val) { return val; }
0044         // Karma only, no post() and no fail() required
0045     };
0046 
0047     // unused_type needs some special handling as well
0048     template <>
0049     struct transform_attribute<unused_type, unused_type>
0050     {
0051         typedef unused_type type;
0052         static unused_type pre(unused_type) { return unused; }
0053     };
0054 
0055     template <>
0056     struct transform_attribute<unused_type const, unused_type>
0057       : transform_attribute<unused_type, unused_type>
0058     {};
0059 
0060     template <typename Attribute>
0061     struct transform_attribute<Attribute, unused_type>
0062       : transform_attribute<unused_type, unused_type>
0063     {};
0064 
0065     template <typename Attribute>
0066     struct transform_attribute<Attribute const, unused_type>
0067       : transform_attribute<unused_type, unused_type>
0068     {};
0069 }}}
0070 
0071 ///////////////////////////////////////////////////////////////////////////////
0072 namespace boost { namespace spirit { namespace traits { namespace detail
0073 {
0074     template <typename Exposed, typename Transformed>
0075     struct transform_attribute_base<Exposed, Transformed, karma::domain>
0076       : karma::transform_attribute<Exposed, Transformed>
0077     {};
0078 }}}}
0079 
0080 #endif