6 #ifndef PRE_SPIRIT_KARMA_SIZE_OF_HPP 7 #define PRE_SPIRIT_KARMA_SIZE_OF_HPP 13 #include <boost/spirit/home/karma/meta_compiler.hpp> 14 #include <boost/spirit/home/karma/generator.hpp> 15 #include <boost/spirit/home/karma/domain.hpp> 16 #include <boost/spirit/home/karma/detail/output_iterator.hpp> 17 #include <boost/spirit/home/support/unused.hpp> 18 #include <boost/spirit/home/support/info.hpp> 19 #include <boost/spirit/home/support/common_terminals.hpp> 20 #include <boost/spirit/home/support/has_semantic_action.hpp> 21 #include <boost/spirit/home/support/handles_container.hpp> 22 #include <boost/spirit/home/karma/detail/attributes.hpp> 24 #include <boost/fusion/include/vector.hpp> 30 namespace pre {
namespace spirit {
namespace karma {
31 namespace mpl = boost::mpl;
32 namespace fusion = boost::fusion;
34 BOOST_SPIRIT_TERMINAL_EX(size_of);
38 namespace boost {
namespace spirit {
44 struct use_directive<karma::domain
45 , terminal_ex<pre::spirit::karma::tag::size_of
46 , fusion::vector1<T> >
51 namespace pre {
namespace spirit {
namespace karma {
53 namespace mpl = boost::mpl;
55 using boost::spirit::buffer_type;
61 template <
typename Subject>
62 struct sizeof_directive : boost::spirit::karma::unary_generator<sizeof_directive<Subject> >
64 typedef Subject subject_type;
66 subject_type::properties::value |
67 boost::spirit::karma::generator_properties::countingbuffer
71 : subject(subject), size(size) {}
73 template <
typename Context,
typename Iterator>
75 : boost::spirit::traits::attribute_of<subject_type, Context, Iterator>
78 template <
typename OutputIterator,
typename Context,
typename Delimiter
80 bool generate(OutputIterator& sink, Context& ctx, Delimiter
const& d
81 , Attribute
const& attr_param)
const 84 boost::spirit::karma::detail::enable_buffering<OutputIterator> buffering(sink);
85 boost::spirit::karma::detail::enable_counting<OutputIterator> counting(sink);
87 bool r = subject.generate(sink, ctx, d, attr_param);
88 size = buffering.buffer_size();
92 template <
typename Context>
93 boost::spirit::info what(Context& context)
const 95 return info(
"size_of", subject.what(context));
104 namespace boost {
namespace spirit {
namespace karma {
109 template <
typename T,
typename Subject,
typename Modifiers>
110 struct make_directive<
111 terminal_ex<
pre::spirit::karma::tag::size_of, fusion::vector1<T> >,
116 template <
typename Terminal>
117 result_type operator()(Terminal & term, Subject
const& subject
120 return result_type(subject, fusion::at_c<0>(term.args));
126 namespace boost {
namespace spirit {
namespace traits
129 template <
typename Subject>
130 struct has_semantic_action<
pre::spirit::karma::sizeof_directive<Subject> >
131 : unary_has_semantic_action<Subject> {};
134 template <
typename Subject,
typename Attribute,
typename Context
136 struct handles_container<pre::spirit::karma::sizeof_directive<Subject>, Attribute
138 : unary_handles_container<Subject, Attribute, Context, Iterator> {};
Definition: size_of.hpp:62
Definition: size_of.hpp:74