]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/repository/home/qi/directive/distinct.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / repository / home / qi / directive / distinct.hpp
1 // Copyright (c) 2001-2011 Hartmut Kaiser
2 // Copyright (c) 2001-2011 Joel de Guzman
3 // Copyright (c) 2003 Vaclav Vesely
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(SPIRIT_REPOSITORY_QI_DISTINCT_MAY_20_2009_0825M)
9 #define SPIRIT_REPOSITORY_QI_DISTINCT_MAY_20_2009_0825M
10
11 #if defined(_MSC_VER)
12 #pragma once
13 #endif
14
15 #include <boost/spirit/home/qi/skip_over.hpp>
16 #include <boost/spirit/home/qi/domain.hpp>
17 #include <boost/spirit/home/qi/parser.hpp>
18 #include <boost/spirit/home/qi/meta_compiler.hpp>
19 #include <boost/spirit/home/qi/detail/unused_skipper.hpp>
20 #include <boost/spirit/home/support/common_terminals.hpp>
21 #include <boost/spirit/home/support/make_component.hpp>
22 #include <boost/spirit/home/support/info.hpp>
23 #include <boost/spirit/home/support/unused.hpp>
24 #include <boost/spirit/home/qi/detail/attributes.hpp>
25 #include <boost/spirit/home/support/string_traits.hpp>
26 #include <boost/spirit/home/qi/auxiliary/eps.hpp>
27 #include <boost/spirit/home/qi/auxiliary/lazy.hpp>
28 #include <boost/spirit/home/qi/directive/lexeme.hpp>
29 #include <boost/spirit/home/qi/operator/not_predicate.hpp>
30
31 #include <boost/spirit/repository/home/support/distinct.hpp>
32
33 #include <boost/fusion/include/at.hpp>
34 #include <boost/fusion/include/vector.hpp>
35
36 ///////////////////////////////////////////////////////////////////////////////
37 namespace boost { namespace spirit
38 {
39 ///////////////////////////////////////////////////////////////////////////
40 // Enablers
41 ///////////////////////////////////////////////////////////////////////////
42
43 // enables distinct(...)[...]
44 template <typename Tail>
45 struct use_directive<qi::domain
46 , terminal_ex<repository::tag::distinct, fusion::vector1<Tail> > >
47 : mpl::true_ {};
48
49 // enables *lazy* distinct(...)[...]
50 template <>
51 struct use_lazy_directive<qi::domain, repository::tag::distinct, 1>
52 : mpl::true_ {};
53
54 }}
55
56 ///////////////////////////////////////////////////////////////////////////////
57 namespace boost { namespace spirit { namespace repository {namespace qi
58 {
59 using repository::distinct_type;
60 using repository::distinct;
61
62 template <typename Subject, typename Tail, typename Modifier>
63 struct distinct_parser
64 : spirit::qi::unary_parser<distinct_parser<Subject, Tail, Modifier> >
65 {
66 template <typename Context, typename Iterator>
67 struct attribute
68 : traits::attribute_of<Subject, Context, Iterator>
69 {};
70
71 distinct_parser(Subject const& subject, Tail const& tail)
72 : subject(subject), tail(tail) {}
73
74 template <typename Iterator, typename Context
75 , typename Skipper, typename Attribute>
76 bool parse(Iterator& first, Iterator const& last
77 , Context& context, Skipper const& skipper, Attribute& attr) const
78 {
79 Iterator iter = first;
80
81 spirit::qi::skip_over(iter, last, skipper);
82 if (!subject.parse(iter, last, context
83 , spirit::qi::detail::unused_skipper<Skipper>(skipper), attr))
84 return false;
85
86 Iterator i = iter;
87 if (tail.parse(i, last, context, unused, unused))
88 return false;
89
90 first = iter;
91 return true;
92 }
93
94 template <typename Context>
95 info what(Context& /*ctx*/) const
96 {
97 return info("distinct");
98 }
99
100 Subject subject;
101 Tail tail;
102 };
103
104 }}}}
105
106 ///////////////////////////////////////////////////////////////////////////////
107 namespace boost { namespace spirit { namespace qi
108 {
109 ///////////////////////////////////////////////////////////////////////////
110 // Parser generators: make_xxx function (objects)
111 ///////////////////////////////////////////////////////////////////////////
112 template <typename Tail, typename Subject, typename Modifiers>
113 struct make_directive<
114 terminal_ex<repository::tag::distinct, fusion::vector1<Tail> >
115 , Subject, Modifiers>
116 {
117 typedef typename result_of::compile<qi::domain, Tail, Modifiers>::type
118 tail_type;
119
120 typedef repository::qi::distinct_parser<
121 Subject, tail_type, Modifiers> result_type;
122
123 template <typename Terminal>
124 result_type operator()(Terminal const& term, Subject const& subject
125 , Modifiers const& modifiers) const
126 {
127 return result_type(subject
128 , compile<qi::domain>(fusion::at_c<0>(term.args), modifiers));
129 }
130 };
131
132 }}}
133
134 namespace boost { namespace spirit { namespace traits
135 {
136 template <typename Subject, typename Tail, typename Modifier>
137 struct has_semantic_action<
138 repository::qi::distinct_parser<Subject, Tail, Modifier> >
139 : unary_has_semantic_action<Subject> {};
140 }}}
141
142 #endif
143