File indexing completed on 2025-12-16 10:09:14
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_SPIRIT_GENERATOR_BINDER_APR_17_2009_0952PM)
0008 #define BOOST_SPIRIT_GENERATOR_BINDER_APR_17_2009_0952PM
0009
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013
0014 #include <boost/fusion/include/at.hpp>
0015 #include <boost/mpl/bool.hpp>
0016 #include <boost/spirit/home/support/has_semantic_action.hpp>
0017
0018 namespace boost { namespace spirit { namespace karma { namespace detail
0019 {
0020
0021 template <typename Generator, typename Auto>
0022 struct generator_binder
0023 {
0024 generator_binder(Generator const& g)
0025 : g(g) {}
0026
0027 template <typename OutputIterator, typename Delimiter, typename Context>
0028 bool call(OutputIterator& sink, Context& context
0029 , Delimiter const& delim, mpl::true_) const
0030 {
0031
0032
0033 return g.generate(sink, context, delim, unused);
0034 }
0035
0036 template <typename OutputIterator, typename Delimiter, typename Context>
0037 bool call(OutputIterator& sink, Context& context
0038 , Delimiter const& delim, mpl::false_) const
0039 {
0040
0041
0042 return g.generate(sink, context, delim
0043 , fusion::at_c<0>(context.attributes));
0044 }
0045
0046 template <typename OutputIterator, typename Delimiter, typename Context>
0047 bool operator()(OutputIterator& sink, Context& context
0048 , Delimiter const& delim) const
0049 {
0050
0051 typedef typename traits::has_semantic_action<Generator>::type auto_rule;
0052 return call(sink, context, delim, auto_rule());
0053 }
0054
0055 Generator g;
0056 };
0057
0058
0059 template <typename Generator>
0060 struct generator_binder<Generator, mpl::true_>
0061 {
0062 generator_binder(Generator const& g)
0063 : g(g) {}
0064
0065 template <typename OutputIterator, typename Delimiter, typename Context>
0066 bool operator()(OutputIterator& sink, Context& context
0067 , Delimiter const& delim) const
0068 {
0069
0070 return g.generate(sink, context, delim
0071 , fusion::at_c<0>(context.attributes));
0072 }
0073
0074 Generator g;
0075 };
0076
0077 template <typename Auto, typename Generator>
0078 inline generator_binder<Generator, Auto>
0079 bind_generator(Generator const& g)
0080 {
0081 return generator_binder<Generator, Auto>(g);
0082 }
0083
0084 }}}}
0085
0086 #endif