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