]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/home/x3/operator/kleene.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / x3 / operator / kleene.hpp
1 /*=============================================================================
2 Copyright (c) 2001-2014 Joel de Guzman
3 Copyright (c) 2001-2011 Hartmut Kaiser
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_KLEENE_JANUARY_07_2007_0818AM)
9 #define SPIRIT_KLEENE_JANUARY_07_2007_0818AM
10
11 #include <boost/spirit/home/x3/core/parser.hpp>
12 #include <boost/spirit/home/x3/support/traits/container_traits.hpp>
13 #include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
14 #include <boost/spirit/home/x3/core/detail/parse_into_container.hpp>
15
16 namespace boost { namespace spirit { namespace x3
17 {
18 template <typename Subject>
19 struct kleene : unary_parser<Subject, kleene<Subject>>
20 {
21 typedef unary_parser<Subject, kleene<Subject>> base_type;
22 static bool const handles_container = true;
23
24 kleene(Subject const& subject)
25 : base_type(subject) {}
26
27 template <typename Iterator, typename Context
28 , typename RContext, typename Attribute>
29 bool parse(Iterator& first, Iterator const& last
30 , Context const& context, RContext& rcontext, Attribute& attr) const
31 {
32 while (detail::parse_into_container(
33 this->subject, first, last, context, rcontext, attr))
34 ;
35 return true;
36 }
37 };
38
39 template <typename Subject>
40 inline kleene<typename extension::as_parser<Subject>::value_type>
41 operator*(Subject const& subject)
42 {
43 return { as_parser(subject) };
44 }
45 }}}
46
47 namespace boost { namespace spirit { namespace x3 { namespace traits
48 {
49 template <typename Subject, typename Context>
50 struct attribute_of<x3::kleene<Subject>, Context>
51 : build_container<
52 typename attribute_of<Subject, Context>::type> {};
53 }}}}
54
55 #endif