File indexing completed on 2025-01-19 09:47:40
0001
0002
0003
0004
0005
0006 #if !defined(BOOST_PP_IS_ITERATING)
0007
0008 #if !defined(BOOST_SPIRIT_KARMA_GENERATE_ATTR_APR_23_2009_0541PM)
0009 #define BOOST_SPIRIT_KARMA_GENERATE_ATTR_APR_23_2009_0541PM
0010
0011 #include <boost/spirit/home/karma/generate.hpp>
0012
0013 #include <boost/fusion/include/vector.hpp>
0014 #include <boost/preprocessor/cat.hpp>
0015 #include <boost/preprocessor/iterate.hpp>
0016 #include <boost/preprocessor/repetition/enum.hpp>
0017 #include <boost/preprocessor/repetition/enum_params.hpp>
0018 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
0019
0020 #define BOOST_PP_FILENAME_1 <boost/spirit/home/karma/generate_attr.hpp>
0021 #define BOOST_PP_ITERATION_LIMITS (2, SPIRIT_ARGUMENTS_LIMIT)
0022 #include BOOST_PP_ITERATE()
0023
0024 #endif
0025
0026
0027
0028
0029
0030
0031 #else
0032
0033 #define N BOOST_PP_ITERATION()
0034 #define BOOST_SPIRIT_KARMA_ATTRIBUTE_REFERENCE(z, n, A) \
0035 BOOST_PP_CAT(A, n) const&
0036
0037 namespace boost { namespace spirit { namespace karma
0038 {
0039
0040 template <typename OutputIterator, typename Properties, typename Expr
0041 , BOOST_PP_ENUM_PARAMS(N, typename A)>
0042 inline bool
0043 generate(
0044 detail::output_iterator<OutputIterator, Properties>& sink
0045 , Expr const& expr
0046 , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& attr))
0047 {
0048
0049
0050
0051 BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
0052
0053 typedef fusion::vector<
0054 BOOST_PP_ENUM(N, BOOST_SPIRIT_KARMA_ATTRIBUTE_REFERENCE, A)
0055 > vector_type;
0056
0057 vector_type attr (BOOST_PP_ENUM_PARAMS(N, attr));
0058 return compile<karma::domain>(expr).generate(sink, unused, unused, attr);
0059 }
0060
0061 template <typename OutputIterator, typename Expr
0062 , BOOST_PP_ENUM_PARAMS(N, typename A)>
0063 inline bool
0064 generate(
0065 OutputIterator& sink_
0066 , Expr const& expr
0067 , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& attr))
0068 {
0069 typedef traits::properties_of<
0070 typename result_of::compile<karma::domain, Expr>::type
0071 > properties;
0072
0073
0074 detail::output_iterator<OutputIterator
0075 , mpl::int_<properties::value> > sink(sink_);
0076 return karma::generate(sink, expr, BOOST_PP_ENUM_PARAMS(N, attr));
0077 }
0078
0079 template <typename OutputIterator, typename Expr
0080 , BOOST_PP_ENUM_PARAMS(N, typename A)>
0081 inline bool
0082 generate(
0083 OutputIterator const& sink_
0084 , Expr const& expr
0085 , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& attr))
0086 {
0087 OutputIterator sink = sink_;
0088 return karma::generate(sink, expr, BOOST_PP_ENUM_PARAMS(N, attr));
0089 }
0090
0091
0092 template <typename OutputIterator, typename Properties, typename Expr
0093 , typename Delimiter, BOOST_PP_ENUM_PARAMS(N, typename A)>
0094 inline bool
0095 generate_delimited(
0096 detail::output_iterator<OutputIterator, Properties>& sink
0097 , Expr const& expr
0098 , Delimiter const& delimiter
0099 , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit
0100 , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& attr))
0101 {
0102
0103
0104
0105
0106 BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
0107 BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Delimiter);
0108
0109 typename result_of::compile<karma::domain, Delimiter>::type const
0110 delimiter_ = compile<karma::domain>(delimiter);
0111
0112 if (pre_delimit == delimit_flag::predelimit &&
0113 !karma::delimit_out(sink, delimiter_))
0114 {
0115 return false;
0116 }
0117
0118 typedef fusion::vector<
0119 BOOST_PP_ENUM(N, BOOST_SPIRIT_KARMA_ATTRIBUTE_REFERENCE, A)
0120 > vector_type;
0121
0122 vector_type attr (BOOST_PP_ENUM_PARAMS(N, attr));
0123 return compile<karma::domain>(expr).
0124 generate(sink, unused, delimiter_, attr);
0125 }
0126
0127 template <typename OutputIterator, typename Expr, typename Delimiter
0128 , BOOST_PP_ENUM_PARAMS(N, typename A)>
0129 inline bool
0130 generate_delimited(
0131 OutputIterator& sink_
0132 , Expr const& expr
0133 , Delimiter const& delimiter
0134 , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit
0135 , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& attr))
0136 {
0137 typedef traits::properties_of<
0138 typename result_of::compile<karma::domain, Expr>::type
0139 > properties;
0140 typedef traits::properties_of<
0141 typename result_of::compile<karma::domain, Delimiter>::type
0142 > delimiter_properties;
0143
0144
0145 detail::output_iterator<OutputIterator
0146 , mpl::int_<properties::value | delimiter_properties::value>
0147 > sink(sink_);
0148 return karma::generate_delimited(sink, expr, delimiter, pre_delimit
0149 , BOOST_PP_ENUM_PARAMS(N, attr));
0150 }
0151
0152 template <typename OutputIterator, typename Expr, typename Delimiter
0153 , BOOST_PP_ENUM_PARAMS(N, typename A)>
0154 inline bool
0155 generate_delimited(
0156 OutputIterator const& sink_
0157 , Expr const& expr
0158 , Delimiter const& delimiter
0159 , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit
0160 , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& attr))
0161 {
0162 OutputIterator sink = sink_;
0163 return karma::generate_delimited(sink, expr, delimiter, pre_delimit
0164 , BOOST_PP_ENUM_PARAMS(N, attr));
0165 }
0166
0167
0168 template <typename OutputIterator, typename Expr, typename Delimiter
0169 , BOOST_PP_ENUM_PARAMS(N, typename A)>
0170 inline bool
0171 generate_delimited(
0172 OutputIterator& sink_
0173 , Expr const& expr
0174 , Delimiter const& delimiter
0175 , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& attr))
0176 {
0177 typedef traits::properties_of<
0178 typename result_of::compile<karma::domain, Expr>::type
0179 > properties;
0180 typedef traits::properties_of<
0181 typename result_of::compile<karma::domain, Delimiter>::type
0182 > delimiter_properties;
0183
0184
0185 detail::output_iterator<OutputIterator
0186 , mpl::int_<properties::value | delimiter_properties::value>
0187 > sink(sink_);
0188 return karma::generate_delimited(sink, expr, delimiter
0189 , delimit_flag::dont_predelimit, BOOST_PP_ENUM_PARAMS(N, attr));
0190 }
0191
0192 template <typename OutputIterator, typename Expr, typename Delimiter
0193 , BOOST_PP_ENUM_PARAMS(N, typename A)>
0194 inline bool
0195 generate_delimited(
0196 OutputIterator const& sink_
0197 , Expr const& expr
0198 , Delimiter const& delimiter
0199 , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& attr))
0200 {
0201 OutputIterator sink = sink_;
0202 return karma::generate_delimited(sink, expr, delimiter
0203 , delimit_flag::dont_predelimit, BOOST_PP_ENUM_PARAMS(N, attr));
0204 }
0205
0206 }}}
0207
0208 #undef BOOST_SPIRIT_KARMA_ATTRIBUTE_REFERENCE
0209 #undef N
0210
0211 #endif
0212