annotate DEPENDENCIES/generic/include/boost/spirit/home/karma/detail/attributes.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright (c) 2001-2011 Hartmut Kaiser
Chris@16 2 // Copyright (c) 2001-2011 Joel de Guzman
Chris@16 3 //
Chris@16 4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6
Chris@16 7 #if !defined(SPIRIT_KARMA_DETAIL_ATTRIBUTES_APR_18_2010_0453PM)
Chris@16 8 #define SPIRIT_KARMA_DETAIL_ATTRIBUTES_APR_18_2010_0453PM
Chris@16 9
Chris@16 10 #include <boost/spirit/home/karma/domain.hpp>
Chris@16 11 #include <boost/spirit/home/support/attributes_fwd.hpp>
Chris@16 12 #include <boost/spirit/home/support/attributes.hpp>
Chris@16 13
Chris@16 14 ///////////////////////////////////////////////////////////////////////////////
Chris@16 15 namespace boost { namespace spirit { namespace karma
Chris@16 16 {
Chris@16 17 template <typename Exposed, typename Transformed, typename Enable = void>
Chris@16 18 struct transform_attribute
Chris@16 19 {
Chris@16 20 typedef Transformed type;
Chris@16 21 static Transformed pre(Exposed& val)
Chris@16 22 {
Chris@16 23 return Transformed(traits::extract_from<Transformed>(val, unused));
Chris@16 24 }
Chris@16 25 // Karma only, no post() and no fail() required
Chris@16 26 };
Chris@16 27
Chris@16 28 template <typename Exposed, typename Transformed>
Chris@16 29 struct transform_attribute<boost::optional<Exposed> const, Transformed
Chris@16 30 , typename disable_if<is_same<boost::optional<Exposed>, Transformed> >::type>
Chris@16 31 {
Chris@16 32 typedef Transformed const& type;
Chris@16 33 static Transformed const& pre(boost::optional<Exposed> const& val)
Chris@16 34 {
Chris@16 35 return boost::get<Transformed>(val);
Chris@16 36 }
Chris@16 37 };
Chris@16 38
Chris@16 39 template <typename Attribute>
Chris@16 40 struct transform_attribute<Attribute const, Attribute>
Chris@16 41 {
Chris@16 42 typedef Attribute const& type;
Chris@16 43 static Attribute const& pre(Attribute const& val) { return val; }
Chris@16 44 // Karma only, no post() and no fail() required
Chris@16 45 };
Chris@16 46
Chris@16 47 // reference types need special handling
Chris@16 48 template <typename Exposed, typename Transformed>
Chris@16 49 struct transform_attribute<Exposed&, Transformed>
Chris@16 50 : transform_attribute<Exposed, Transformed>
Chris@16 51 {};
Chris@16 52
Chris@16 53 template <typename Exposed, typename Transformed>
Chris@16 54 struct transform_attribute<Exposed const&, Transformed>
Chris@16 55 : transform_attribute<Exposed const, Transformed>
Chris@16 56 {};
Chris@16 57
Chris@16 58 template <typename Attribute>
Chris@16 59 struct transform_attribute<Attribute const&, Attribute>
Chris@16 60 : transform_attribute<Attribute const, Attribute>
Chris@16 61 {};
Chris@16 62
Chris@16 63 // unused_type needs some special handling as well
Chris@16 64 template <>
Chris@16 65 struct transform_attribute<unused_type, unused_type>
Chris@16 66 {
Chris@16 67 typedef unused_type type;
Chris@16 68 static unused_type pre(unused_type) { return unused; }
Chris@16 69 };
Chris@16 70
Chris@16 71 template <>
Chris@16 72 struct transform_attribute<unused_type const, unused_type>
Chris@16 73 : transform_attribute<unused_type, unused_type>
Chris@16 74 {};
Chris@16 75
Chris@16 76 template <typename Attribute>
Chris@16 77 struct transform_attribute<unused_type, Attribute>
Chris@16 78 : transform_attribute<unused_type, unused_type>
Chris@16 79 {};
Chris@16 80
Chris@16 81 template <typename Attribute>
Chris@16 82 struct transform_attribute<unused_type const, Attribute>
Chris@16 83 : transform_attribute<unused_type, unused_type>
Chris@16 84 {};
Chris@16 85
Chris@16 86 template <typename Attribute>
Chris@16 87 struct transform_attribute<Attribute, unused_type>
Chris@16 88 : transform_attribute<unused_type, unused_type>
Chris@16 89 {};
Chris@16 90
Chris@16 91 template <typename Attribute>
Chris@16 92 struct transform_attribute<Attribute const, unused_type>
Chris@16 93 : transform_attribute<unused_type, unused_type>
Chris@16 94 {};
Chris@16 95 }}}
Chris@16 96
Chris@16 97 ///////////////////////////////////////////////////////////////////////////////
Chris@16 98 namespace boost { namespace spirit { namespace traits
Chris@16 99 {
Chris@16 100 template <typename Exposed, typename Transformed>
Chris@16 101 struct transform_attribute<Exposed, Transformed, karma::domain>
Chris@16 102 : karma::transform_attribute<Exposed, Transformed>
Chris@16 103 {};
Chris@16 104 }}}
Chris@16 105
Chris@16 106 #endif
Chris@16 107
Chris@16 108