File indexing completed on 2025-01-18 09:52:29
0001
0002
0003
0004
0005
0006 #if !defined(BOOST_SPIRIT_REPOSITORY_KARMA_CONFIX_AUG_19_2008_1041AM)
0007 #define BOOST_SPIRIT_REPOSITORY_KARMA_CONFIX_AUG_19_2008_1041AM
0008
0009 #if defined(_MSC_VER)
0010 #pragma once
0011 #endif
0012
0013 #include <boost/spirit/home/support/common_terminals.hpp>
0014 #include <boost/spirit/home/support/info.hpp>
0015 #include <boost/spirit/home/support/unused.hpp>
0016 #include <boost/spirit/home/karma/detail/attributes.hpp>
0017 #include <boost/spirit/home/karma/domain.hpp>
0018 #include <boost/spirit/home/karma/meta_compiler.hpp>
0019
0020 #include <boost/spirit/repository/home/support/confix.hpp>
0021
0022 #include <boost/fusion/include/vector.hpp>
0023 #include <boost/mpl/or.hpp>
0024
0025
0026 namespace boost { namespace spirit
0027 {
0028
0029
0030
0031
0032
0033 template <typename Prefix, typename Suffix>
0034 struct use_directive<karma::domain
0035 , terminal_ex<repository::tag::confix, fusion::vector2<Prefix, Suffix> > >
0036 : mpl::true_ {};
0037
0038
0039 template <>
0040 struct use_lazy_directive<karma::domain, repository::tag::confix, 2>
0041 : mpl::true_ {};
0042
0043 }}
0044
0045
0046 namespace boost { namespace spirit { namespace repository { namespace karma
0047 {
0048 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
0049 using repository::confix;
0050 #endif
0051 using repository::confix_type;
0052
0053
0054 template <typename Subject, typename Prefix, typename Suffix>
0055 struct confix_generator
0056 : spirit::karma::primitive_generator<confix_generator<Subject, Prefix, Suffix> >
0057 {
0058 typedef Subject subject_type;
0059
0060 template <typename Context, typename Iterator>
0061 struct attribute
0062 : traits::attribute_of<subject_type, Context, Iterator>
0063 {};
0064
0065 confix_generator(Subject const& subject, Prefix const& prefix
0066 , Suffix const& suffix)
0067 : subject(subject), prefix(prefix), suffix(suffix) {}
0068
0069
0070 template <typename OutputIterator, typename Context, typename Delimiter
0071 , typename Attribute>
0072 bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
0073 , Attribute const& attr) const
0074 {
0075
0076 return prefix.generate(sink, ctx, d, unused) &&
0077 subject.generate(sink, ctx, d, attr) &&
0078 suffix.generate(sink, ctx, d, unused);
0079 }
0080
0081 template <typename Context>
0082 info what(Context const& ctx) const
0083 {
0084 return info("confix", subject.what(ctx));
0085 }
0086
0087 Subject subject;
0088 Prefix prefix;
0089 Suffix suffix;
0090 };
0091
0092 }}}}
0093
0094
0095 namespace boost { namespace spirit { namespace karma
0096 {
0097
0098
0099
0100
0101
0102 template <typename Prefix, typename Suffix, typename Subject
0103 , typename Modifiers>
0104 struct make_directive<
0105 terminal_ex<repository::tag::confix, fusion::vector2<Prefix, Suffix> >
0106 , Subject, Modifiers>
0107 {
0108 typedef typename
0109 result_of::compile<karma::domain, Prefix, Modifiers>::type
0110 prefix_type;
0111 typedef typename
0112 result_of::compile<karma::domain, Suffix, Modifiers>::type
0113 suffix_type;
0114
0115 typedef repository::karma::confix_generator<
0116 Subject, prefix_type, suffix_type> result_type;
0117
0118 template <typename Terminal>
0119 result_type operator()(Terminal const& term, Subject const& subject
0120 , Modifiers const& modifiers) const
0121 {
0122 return result_type(subject
0123 , compile<karma::domain>(fusion::at_c<0>(term.args), modifiers)
0124 , compile<karma::domain>(fusion::at_c<1>(term.args), modifiers));
0125 }
0126 };
0127
0128 }}}
0129
0130 namespace boost { namespace spirit { namespace traits
0131 {
0132 template <typename Subject, typename Prefix, typename Suffix>
0133 struct has_semantic_action<
0134 repository::karma::confix_generator<Subject, Prefix, Suffix> >
0135 : mpl::or_<
0136 has_semantic_action<Subject>
0137 , has_semantic_action<Prefix>
0138 , has_semantic_action<Suffix>
0139 > {};
0140 }}}
0141
0142 #endif