]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/home/karma/nonterminal/detail/parameterized.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / karma / nonterminal / detail / parameterized.hpp
1 // Copyright (c) 2001-2011 Joel de Guzman
2 // Copyright (c) 2001-2011 Hartmut Kaiser
3 // Copyright (c) 2009 Francois Barel
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_KARMA_PARAMETERIZED_AUGUST_09_2009_0601AM)
9 #define BOOST_SPIRIT_KARMA_PARAMETERIZED_AUGUST_09_2009_0601AM
10
11 #if defined(_MSC_VER)
12 #pragma once
13 #endif
14
15 #include <boost/ref.hpp>
16
17 #include <boost/spirit/home/support/handles_container.hpp>
18 #include <boost/spirit/home/karma/generator.hpp>
19
20 namespace boost { namespace spirit { namespace karma
21 {
22 ///////////////////////////////////////////////////////////////////////////
23 // parameterized_nonterminal: generator representing the invocation of a
24 // nonterminal, passing inherited attributes
25 ///////////////////////////////////////////////////////////////////////////
26 template <typename Subject, typename Params>
27 struct parameterized_nonterminal
28 : generator<parameterized_nonterminal<Subject, Params> >
29 {
30 typedef mpl::int_<generator_properties::all_properties> properties;
31
32 parameterized_nonterminal(Subject const& subject, Params const& params)
33 : ref(subject), params(params)
34 {
35 }
36
37 template <typename Context, typename Unused>
38 struct attribute
39 // Forward to subject.
40 : Subject::template attribute<Context, Unused> {};
41
42 template <typename OutputIterator, typename Context, typename Delimiter
43 , typename Attribute>
44 bool generate(OutputIterator& sink, Context& context
45 , Delimiter const& delim, Attribute const& attr) const
46 {
47 // Forward to subject, passing the additional
48 // params argument to generate.
49 return ref.get().generate(sink, context, delim, attr, params);
50 }
51
52 template <typename Context>
53 info what(Context& context) const
54 {
55 // Forward to subject.
56 return ref.get().what(context);
57 }
58
59 boost::reference_wrapper<Subject const> ref;
60 Params params;
61 };
62 }}}
63
64 namespace boost { namespace spirit { namespace traits
65 {
66 ///////////////////////////////////////////////////////////////////////////
67 template <typename Subject, typename Params, typename Attribute
68 , typename Context, typename Iterator>
69 struct handles_container<karma::parameterized_nonterminal<Subject, Params>
70 , Attribute, Context, Iterator>
71 : handles_container<typename remove_const<Subject>::type
72 , Attribute, Context, Iterator>
73 {};
74 }}}
75
76 #endif