]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/include/boost/metaparse/v1/keyword.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / metaparse / include / boost / metaparse / v1 / keyword.hpp
1 #ifndef BOOST_METAPARSE_V1_KEYWORD_HPP
2 #define BOOST_METAPARSE_V1_KEYWORD_HPP
3
4 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2009 - 2010.
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8
9 #include <boost/metaparse/v1/impl/void_.hpp>
10 #include <boost/metaparse/v1/lit.hpp>
11 #include <boost/metaparse/v1/return_.hpp>
12 #include <boost/metaparse/v1/is_error.hpp>
13 #include <boost/metaparse/v1/get_remaining.hpp>
14 #include <boost/metaparse/v1/get_position.hpp>
15
16 #include <boost/mpl/if.hpp>
17 #include <boost/mpl/eval_if.hpp>
18 #include <boost/mpl/empty.hpp>
19 #include <boost/mpl/pop_front.hpp>
20 #include <boost/mpl/front.hpp>
21
22 namespace boost
23 {
24 namespace metaparse
25 {
26 namespace v1
27 {
28 // Does not consume/check anything after the keyword
29 template <class Kw, class ResultType = impl::void_>
30 struct keyword
31 {
32 private:
33 struct nonempty
34 {
35 private:
36 typedef lit<typename boost::mpl::front<Kw>::type> next_char_parser;
37
38 typedef
39 keyword<typename boost::mpl::pop_front<Kw>::type, ResultType>
40 rest_parser;
41
42 template <class S, class Pos>
43 struct apply_unchecked :
44 rest_parser::template apply<
45 typename get_remaining<
46 typename next_char_parser::template apply<S, Pos>
47 >::type,
48 typename get_position<
49 typename next_char_parser::template apply<S, Pos>
50 >::type
51 >
52 {};
53 public:
54 template <class S, class Pos>
55 struct apply :
56 boost::mpl::eval_if<
57 typename is_error<
58 typename next_char_parser::template apply<S, Pos>
59 >::type,
60 typename next_char_parser::template apply<S, Pos>,
61 apply_unchecked<S, Pos>
62 >
63 {};
64 };
65 public:
66 typedef keyword type;
67
68 template <class S, class Pos>
69 struct apply :
70 boost::mpl::if_<
71 boost::mpl::empty<Kw>,
72 return_<ResultType>,
73 nonempty
74 >::type::template apply<S, Pos>
75 {};
76 };
77 }
78 }
79 }
80
81 #endif
82