annotate DEPENDENCIES/generic/include/boost/spirit/home/karma/directive/delimit.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright (c) 2001-2011 Hartmut Kaiser
Chris@16 2 //
Chris@16 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 5
Chris@16 6 #if !defined(BOOST_SPIRIT_KARMA_DELIMIT_MAR_02_2007_0217PM)
Chris@16 7 #define BOOST_SPIRIT_KARMA_DELIMIT_MAR_02_2007_0217PM
Chris@16 8
Chris@16 9 #if defined(_MSC_VER)
Chris@16 10 #pragma once
Chris@16 11 #endif
Chris@16 12
Chris@16 13 #include <boost/spirit/home/karma/meta_compiler.hpp>
Chris@16 14 #include <boost/spirit/home/karma/generator.hpp>
Chris@16 15 #include <boost/spirit/home/karma/domain.hpp>
Chris@16 16 #include <boost/spirit/home/karma/detail/unused_delimiter.hpp>
Chris@16 17 #include <boost/spirit/home/karma/delimit_out.hpp>
Chris@16 18 #include <boost/spirit/home/karma/auxiliary/lazy.hpp>
Chris@16 19 #include <boost/spirit/home/support/unused.hpp>
Chris@16 20 #include <boost/spirit/home/support/common_terminals.hpp>
Chris@16 21 #include <boost/spirit/home/support/has_semantic_action.hpp>
Chris@16 22 #include <boost/spirit/home/support/handles_container.hpp>
Chris@16 23 #include <boost/spirit/home/karma/detail/attributes.hpp>
Chris@16 24 #include <boost/spirit/home/support/info.hpp>
Chris@16 25 #include <boost/fusion/include/at.hpp>
Chris@16 26 #include <boost/fusion/include/vector.hpp>
Chris@16 27
Chris@16 28 namespace boost { namespace spirit
Chris@16 29 {
Chris@16 30 ///////////////////////////////////////////////////////////////////////////
Chris@16 31 // Enablers
Chris@16 32 ///////////////////////////////////////////////////////////////////////////
Chris@16 33 template <>
Chris@16 34 struct use_directive<karma::domain, tag::delimit> // enables delimit[]
Chris@16 35 : mpl::true_ {};
Chris@16 36
Chris@16 37 // enables delimit(d)[g], where d is a generator
Chris@16 38 template <typename T>
Chris@16 39 struct use_directive<karma::domain
Chris@16 40 , terminal_ex<tag::delimit, fusion::vector1<T> > >
Chris@16 41 : boost::spirit::traits::matches<karma::domain, T> {};
Chris@16 42
Chris@16 43 // enables *lazy* delimit(d)[g]
Chris@16 44 template <>
Chris@16 45 struct use_lazy_directive<karma::domain, tag::delimit, 1>
Chris@16 46 : mpl::true_ {};
Chris@16 47
Chris@16 48 }}
Chris@16 49
Chris@16 50 namespace boost { namespace spirit { namespace karma
Chris@16 51 {
Chris@16 52 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
Chris@16 53 using spirit::delimit;
Chris@16 54 #endif
Chris@16 55 using spirit::delimit_type;
Chris@16 56
Chris@16 57 ///////////////////////////////////////////////////////////////////////////
Chris@16 58 // The redelimit_generator generator is used for delimit[...] directives.
Chris@16 59 ///////////////////////////////////////////////////////////////////////////
Chris@16 60 template <typename Subject>
Chris@16 61 struct redelimit_generator : unary_generator<redelimit_generator<Subject> >
Chris@16 62 {
Chris@16 63 typedef Subject subject_type;
Chris@16 64
Chris@16 65 typedef typename subject_type::properties properties;
Chris@16 66
Chris@16 67 template <typename Context, typename Iterator>
Chris@16 68 struct attribute
Chris@16 69 : traits::attribute_of<subject_type, Context, Iterator>
Chris@16 70 {};
Chris@16 71
Chris@16 72 redelimit_generator(Subject const& subject)
Chris@16 73 : subject(subject) {}
Chris@16 74
Chris@16 75 template <typename OutputIterator, typename Context, typename Delimiter
Chris@16 76 , typename Attribute>
Chris@16 77 bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
Chris@16 78 , Attribute const& attr) const
Chris@16 79 {
Chris@16 80 // The delimit_space generator simply dispatches to the embedded
Chris@16 81 // generator while supplying either the delimiter which has been
Chris@16 82 // used before a surrounding verbatim[] directive or a single
Chris@16 83 // space as the new delimiter to use (if no surrounding verbatim[]
Chris@16 84 // was specified).
Chris@16 85 return subject.generate(sink, ctx
Chris@16 86 , detail::get_delimiter(d, compile<karma::domain>(' ')), attr);
Chris@16 87 }
Chris@16 88
Chris@16 89 template <typename Context>
Chris@16 90 info what(Context& context) const
Chris@16 91 {
Chris@16 92 return info("delimit", subject.what(context));
Chris@16 93 }
Chris@16 94
Chris@16 95 Subject subject;
Chris@16 96 };
Chris@16 97
Chris@16 98 ///////////////////////////////////////////////////////////////////////////
Chris@16 99 // The delimit_generator is used for delimit(d)[...] directives.
Chris@16 100 ///////////////////////////////////////////////////////////////////////////
Chris@16 101 template <typename Subject, typename Delimiter>
Chris@16 102 struct delimit_generator
Chris@16 103 : unary_generator<delimit_generator<Subject, Delimiter> >
Chris@16 104 {
Chris@16 105 typedef Subject subject_type;
Chris@16 106 typedef Delimiter delimiter_type;
Chris@16 107
Chris@16 108 typedef typename subject_type::properties properties;
Chris@16 109
Chris@16 110 template <typename Context, typename Iterator>
Chris@16 111 struct attribute
Chris@16 112 : traits::attribute_of<subject_type, Context, Iterator>
Chris@16 113 {};
Chris@16 114
Chris@16 115 delimit_generator(Subject const& subject, Delimiter const& delimiter)
Chris@16 116 : subject(subject), delimiter(delimiter) {}
Chris@16 117
Chris@16 118 template <typename OutputIterator, typename Context
Chris@16 119 , typename Delimiter_, typename Attribute>
Chris@16 120 bool generate(OutputIterator& sink, Context& ctx, Delimiter_ const&
Chris@16 121 , Attribute const& attr) const
Chris@16 122 {
Chris@16 123 // the delimit generator simply dispatches to the embedded
Chris@16 124 // generator while supplying it's argument as the new delimiter
Chris@16 125 // to use
Chris@16 126 return subject.generate(sink, ctx, delimiter, attr);
Chris@16 127 }
Chris@16 128
Chris@16 129 template <typename Context>
Chris@16 130 info what(Context& context) const
Chris@16 131 {
Chris@16 132 return info("delimit", subject.what(context));
Chris@16 133 }
Chris@16 134
Chris@16 135 Subject subject;
Chris@16 136 Delimiter delimiter;
Chris@16 137 };
Chris@16 138
Chris@16 139 ///////////////////////////////////////////////////////////////////////////
Chris@16 140 // Generator generators: make_xxx function (objects)
Chris@16 141 ///////////////////////////////////////////////////////////////////////////
Chris@16 142 template <typename Subject, typename Modifiers>
Chris@16 143 struct make_directive<tag::delimit, Subject, Modifiers>
Chris@16 144 {
Chris@16 145 typedef redelimit_generator<Subject> result_type;
Chris@16 146 result_type operator()(unused_type, Subject const& subject
Chris@16 147 , unused_type) const
Chris@16 148 {
Chris@16 149 return result_type(subject);
Chris@16 150 }
Chris@16 151 };
Chris@16 152
Chris@16 153 template <typename Delimiter, typename Subject, typename Modifiers>
Chris@16 154 struct make_directive<
Chris@16 155 terminal_ex<tag::delimit, fusion::vector1<Delimiter> >
Chris@16 156 , Subject, Modifiers>
Chris@16 157 {
Chris@16 158 typedef typename
Chris@16 159 result_of::compile<karma::domain, Delimiter, Modifiers>::type
Chris@16 160 delimiter_type;
Chris@16 161
Chris@16 162 typedef delimit_generator<Subject, delimiter_type> result_type;
Chris@16 163
Chris@16 164 template <typename Terminal>
Chris@16 165 result_type operator()(Terminal const& term, Subject const& subject
Chris@16 166 , unused_type) const
Chris@16 167 {
Chris@16 168 return result_type(subject
Chris@16 169 , compile<karma::domain>(fusion::at_c<0>(term.args)));
Chris@16 170 }
Chris@16 171 };
Chris@16 172
Chris@16 173 }}}
Chris@16 174
Chris@16 175 namespace boost { namespace spirit { namespace traits
Chris@16 176 {
Chris@16 177 ///////////////////////////////////////////////////////////////////////////
Chris@16 178 template <typename Subject>
Chris@16 179 struct has_semantic_action<karma::redelimit_generator<Subject> >
Chris@16 180 : unary_has_semantic_action<Subject> {};
Chris@16 181
Chris@16 182 template <typename Subject, typename Delimiter>
Chris@16 183 struct has_semantic_action<karma::delimit_generator<Subject, Delimiter> >
Chris@16 184 : unary_has_semantic_action<Subject> {};
Chris@16 185
Chris@16 186 ///////////////////////////////////////////////////////////////////////////
Chris@16 187 template <typename Subject, typename Attribute
Chris@16 188 , typename Context, typename Iterator>
Chris@16 189 struct handles_container<karma::redelimit_generator<Subject>, Attribute
Chris@16 190 , Context, Iterator>
Chris@16 191 : unary_handles_container<Subject, Attribute, Context, Iterator> {};
Chris@16 192
Chris@16 193 template <typename Subject, typename Delimiter, typename Attribute
Chris@16 194 , typename Context, typename Iterator>
Chris@16 195 struct handles_container<karma::delimit_generator<Subject, Delimiter>
Chris@16 196 , Attribute, Context, Iterator>
Chris@16 197 : unary_handles_container<Subject, Attribute, Context, Iterator> {};
Chris@16 198 }}}
Chris@16 199
Chris@16 200 #endif