]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/home/qi/auxiliary/attr.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / qi / auxiliary / attr.hpp
1 /*=============================================================================
2 Copyright (c) 2001-2011 Hartmut Kaiser
3 Copyright (c) 2001-2011 Joel de Guzman
4
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #if !defined(BOOST_SPIRIT_ATTR_JUL_23_2008_0956AM)
9 #define BOOST_SPIRIT_ATTR_JUL_23_2008_0956AM
10
11 #if defined(_MSC_VER)
12 #pragma once
13 #endif
14
15 #include <boost/mpl/bool.hpp>
16 #include <boost/spirit/home/qi/domain.hpp>
17 #include <boost/spirit/home/qi/parser.hpp>
18 #include <boost/spirit/home/qi/detail/assign_to.hpp>
19 #include <boost/spirit/home/qi/meta_compiler.hpp>
20 #include <boost/spirit/home/support/common_terminals.hpp>
21 #include <boost/spirit/home/support/handles_container.hpp>
22 #include <boost/type_traits/add_reference.hpp>
23 #include <boost/type_traits/add_const.hpp>
24 #include <boost/type_traits/remove_const.hpp>
25
26 namespace boost { namespace spirit
27 {
28 ///////////////////////////////////////////////////////////////////////////
29 // Enablers
30 ///////////////////////////////////////////////////////////////////////////
31 template <typename A0> // enables attr()
32 struct use_terminal<
33 qi::domain, terminal_ex<tag::attr, fusion::vector1<A0> > >
34 : mpl::true_ {};
35
36 template <> // enables *lazy* attr()
37 struct use_lazy_terminal<qi::domain, tag::attr, 1>
38 : mpl::true_ {};
39
40 }}
41
42 namespace boost { namespace spirit { namespace qi
43 {
44 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
45 using spirit::attr;
46 #endif
47 using spirit::attr_type;
48
49 template <typename Value>
50 struct attr_parser : primitive_parser<attr_parser<Value> >
51 {
52 template <typename Context, typename Iterator>
53 struct attribute : remove_const<Value> {};
54
55 attr_parser(typename add_reference<Value>::type value)
56 : value_(value) {}
57
58 template <typename Iterator, typename Context
59 , typename Skipper, typename Attribute>
60 bool parse(Iterator& /*first*/, Iterator const& /*last*/
61 , Context& /*context*/, Skipper const& /*skipper*/
62 , Attribute& attr_) const
63 {
64 spirit::traits::assign_to(value_, attr_);
65 return true; // never consume any input, succeed always
66 }
67
68 template <typename Context>
69 info what(Context& /*context*/) const
70 {
71 return info("attr");
72 }
73
74 Value value_;
75
76 private:
77 // silence MSVC warning C4512: assignment operator could not be generated
78 attr_parser& operator= (attr_parser const&);
79 };
80
81 ///////////////////////////////////////////////////////////////////////////
82 // Parser generators: make_xxx function (objects)
83 ///////////////////////////////////////////////////////////////////////////
84 template <typename Modifiers, typename A0>
85 struct make_primitive<
86 terminal_ex<tag::attr, fusion::vector1<A0> >
87 , Modifiers>
88 {
89 typedef typename add_const<A0>::type const_value;
90 typedef attr_parser<const_value> result_type;
91
92 template <typename Terminal>
93 result_type operator()(Terminal const& term, unused_type) const
94 {
95 return result_type(fusion::at_c<0>(term.args));
96 }
97 };
98 }}}
99
100 namespace boost { namespace spirit { namespace traits
101 {
102 ///////////////////////////////////////////////////////////////////////////
103 template <typename T, typename Attr, typename Context, typename Iterator>
104 struct handles_container<qi::attr_parser<T>, Attr, Context, Iterator>
105 : traits::is_container<Attr> {};
106 }}}
107
108 #endif
109
110