File indexing completed on 2025-01-19 09:47:36
0001
0002
0003
0004
0005
0006 #ifndef BOOST_SPIRIT_KARMA_DIRECTIVE_OMIT_HPP
0007 #define BOOST_SPIRIT_KARMA_DIRECTIVE_OMIT_HPP
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/generator.hpp>
0015 #include <boost/spirit/home/karma/domain.hpp>
0016 #include <boost/spirit/home/support/unused.hpp>
0017 #include <boost/spirit/home/support/info.hpp>
0018 #include <boost/spirit/home/support/common_terminals.hpp>
0019 #include <boost/spirit/home/support/has_semantic_action.hpp>
0020 #include <boost/spirit/home/support/handles_container.hpp>
0021 #include <boost/spirit/home/karma/detail/attributes.hpp>
0022 #include <boost/spirit/home/karma/detail/output_iterator.hpp>
0023
0024 namespace boost { namespace spirit
0025 {
0026
0027
0028
0029 template <>
0030 struct use_directive<karma::domain, tag::omit>
0031 : mpl::true_ {};
0032
0033 template <>
0034 struct use_directive<karma::domain, tag::skip>
0035 : mpl::true_ {};
0036 }}
0037
0038 namespace boost { namespace spirit { namespace karma
0039 {
0040 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
0041 using spirit::omit;
0042 using spirit::skip;
0043 #endif
0044 using spirit::omit_type;
0045 using spirit::skip_type;
0046
0047
0048
0049
0050
0051 template <typename Subject, bool Execute>
0052 struct omit_directive : unary_generator<omit_directive<Subject, Execute> >
0053 {
0054 typedef Subject subject_type;
0055
0056 typedef mpl::int_<
0057 generator_properties::disabling | subject_type::properties::value
0058 > properties;
0059
0060 omit_directive(Subject const& subject)
0061 : subject(subject) {}
0062
0063 template <typename Context, typename Iterator = unused_type>
0064 struct attribute
0065 : traits::attribute_of<subject_type, Context, Iterator>
0066 {};
0067
0068 template <typename OutputIterator, typename Context, typename Delimiter
0069 , typename Attribute>
0070 bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
0071 , Attribute const& attr) const
0072 {
0073
0074
0075
0076
0077 #if defined(_MSC_VER) && _MSC_VER < 1900
0078 # pragma warning(push)
0079 # pragma warning(disable: 4127)
0080 #endif
0081
0082 if (Execute) {
0083 #if defined(_MSC_VER) && _MSC_VER < 1900
0084 # pragma warning(pop)
0085 #endif
0086
0087 detail::disable_output<OutputIterator> disable(sink);
0088 return subject.generate(sink, ctx, d, attr);
0089 }
0090 return true;
0091 }
0092
0093 template <typename Context>
0094 info what(Context& context) const
0095 {
0096 return info(Execute ? "omit" : "skip", subject.what(context));
0097 }
0098
0099 Subject subject;
0100 };
0101
0102
0103
0104
0105 template <typename Subject, typename Modifiers>
0106 struct make_directive<tag::omit, Subject, Modifiers>
0107 {
0108 typedef omit_directive<Subject, true> result_type;
0109 result_type operator()(unused_type, Subject const& subject
0110 , unused_type) const
0111 {
0112 return result_type(subject);
0113 }
0114 };
0115
0116 template <typename Subject, typename Modifiers>
0117 struct make_directive<tag::skip, Subject, Modifiers>
0118 {
0119 typedef omit_directive<Subject, false> result_type;
0120 result_type operator()(unused_type, Subject const& subject
0121 , unused_type) const
0122 {
0123 return result_type(subject);
0124 }
0125 };
0126 }}}
0127
0128 namespace boost { namespace spirit { namespace traits
0129 {
0130
0131 template <typename Subject, bool Execute>
0132 struct has_semantic_action<karma::omit_directive<Subject, Execute> >
0133 : unary_has_semantic_action<Subject> {};
0134
0135
0136 template <typename Subject, bool Execute, typename Attribute
0137 , typename Context, typename Iterator>
0138 struct handles_container<karma::omit_directive<Subject, Execute>, Attribute
0139 , Context, Iterator>
0140 : unary_handles_container<Subject, Attribute, Context, Iterator> {};
0141 }}}
0142
0143 #endif