1 // Copyright (c) 2001-2011 Joel de Guzman
2 // Copyright (c) 2001-2011 Hartmut Kaiser
3 // Copyright (c) 2009 Francois Barel
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)
8 #if !defined(BOOST_SPIRIT_KARMA_PARAMETERIZED_AUGUST_09_2009_0601AM)
9 #define BOOST_SPIRIT_KARMA_PARAMETERIZED_AUGUST_09_2009_0601AM
15 #include <boost/ref.hpp>
17 #include <boost/spirit/home/support/handles_container.hpp>
18 #include <boost/spirit/home/karma/generator.hpp>
20 namespace boost { namespace spirit { namespace karma
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> >
30 typedef mpl::int_<generator_properties::all_properties> properties;
32 parameterized_nonterminal(Subject const& subject, Params const& params)
33 : ref(subject), params(params)
37 template <typename Context, typename Unused>
39 // Forward to subject.
40 : Subject::template attribute<Context, Unused> {};
42 template <typename OutputIterator, typename Context, typename Delimiter
44 bool generate(OutputIterator& sink, Context& context
45 , Delimiter const& delim, Attribute const& attr) const
47 // Forward to subject, passing the additional
48 // params argument to generate.
49 return ref.get().generate(sink, context, delim, attr, params);
52 template <typename Context>
53 info what(Context& context) const
55 // Forward to subject.
56 return ref.get().what(context);
59 boost::reference_wrapper<Subject const> ref;
64 namespace boost { namespace spirit { namespace traits
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>