File indexing completed on 2025-01-19 09:47:35
0001
0002
0003
0004
0005
0006 #if !defined(BOOST_SPIRIT_KARMA_DETAIL_GENERATE_FEB_20_2007_0959AM)
0007 #define BOOST_SPIRIT_KARMA_DETAIL_GENERATE_FEB_20_2007_0959AM
0008
0009 #if defined(_MSC_VER)
0010 #pragma once
0011 #endif
0012
0013 #include <boost/spirit/home/karma/meta_compiler.hpp>
0014 #include <boost/spirit/home/karma/delimit_out.hpp>
0015 #include <boost/spirit/home/karma/delimit_flag.hpp>
0016 #include <boost/spirit/home/karma/detail/output_iterator.hpp>
0017 #include <boost/spirit/home/support/unused.hpp>
0018 #include <boost/mpl/assert.hpp>
0019 #include <boost/mpl/bool.hpp>
0020
0021 namespace boost { namespace spirit { namespace karma { namespace detail
0022 {
0023
0024 template <typename Expr, typename Enable = void>
0025 struct generate_impl
0026 {
0027
0028
0029
0030
0031
0032 BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
0033 };
0034
0035 template <typename Expr>
0036 struct generate_impl<Expr
0037 , typename enable_if<traits::matches<karma::domain, Expr> >::type>
0038 {
0039 template <typename OutputIterator>
0040 static bool call(
0041 OutputIterator& target_sink
0042 , Expr const& expr)
0043 {
0044 typedef traits::properties_of<
0045 typename result_of::compile<karma::domain, Expr>::type
0046 > properties;
0047
0048
0049 output_iterator<OutputIterator
0050 , mpl::int_<properties::value> > sink(target_sink);
0051 return compile<karma::domain>(expr).
0052 generate(sink, unused, unused, unused);
0053 }
0054
0055 template <typename OutputIterator, typename Properties>
0056 static bool call(
0057 detail::output_iterator<OutputIterator, Properties>& sink
0058 , Expr const& expr)
0059 {
0060 return compile<karma::domain>(expr).
0061 generate(sink, unused, unused, unused);
0062 }
0063 };
0064
0065
0066 template <typename Expr, typename Enable = void>
0067 struct generate_delimited_impl
0068 {
0069
0070
0071
0072
0073
0074 BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
0075 };
0076
0077 template <typename Expr>
0078 struct generate_delimited_impl<Expr
0079 , typename enable_if<traits::matches<karma::domain, Expr> >::type>
0080 {
0081 template <typename OutputIterator, typename Delimiter>
0082 static bool call(
0083 OutputIterator& target_sink
0084 , Expr const& expr
0085 , Delimiter const& delimiter
0086 , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit)
0087 {
0088 typedef traits::properties_of<
0089 typename result_of::compile<karma::domain, Expr>::type
0090 > properties;
0091 typedef traits::properties_of<
0092 typename result_of::compile<karma::domain, Delimiter>::type
0093 > delimiter_properties;
0094
0095
0096 detail::output_iterator<OutputIterator
0097 , mpl::int_<properties::value | delimiter_properties::value>
0098 > sink(target_sink);
0099 return call(sink, expr, delimiter, pre_delimit);
0100 }
0101
0102 template <typename OutputIterator, typename Properties
0103 , typename Delimiter>
0104 static bool call(
0105 detail::output_iterator<OutputIterator, Properties>& sink
0106 , Expr const& expr
0107 , Delimiter const& delimiter
0108 , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit)
0109 {
0110
0111
0112
0113 BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Delimiter);
0114
0115 typename result_of::compile<karma::domain, Delimiter>::type const
0116 delimiter_ = compile<karma::domain>(delimiter);
0117
0118 if (pre_delimit == delimit_flag::predelimit &&
0119 !karma::delimit_out(sink, delimiter_))
0120 {
0121 return false;
0122 }
0123 return compile<karma::domain>(expr).
0124 generate(sink, unused, delimiter_, unused);
0125 }
0126 };
0127
0128 }}}}
0129
0130 #endif
0131