Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:47:37

0001 //  Copyright (c) 2001-2011 Hartmut Kaiser
0002 // 
0003 //  Distributed under the Boost Software License, Version 1.0. (See accompanying 
0004 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #if !defined(BOOST_SPIRIT_KARMA_VERBATIM_MAR_02_2007_0303PM)
0007 #define BOOST_SPIRIT_KARMA_VERBATIM_MAR_02_2007_0303PM
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/karma/detail/unused_delimiter.hpp>
0017 #include <boost/spirit/home/karma/delimit_out.hpp>
0018 #include <boost/spirit/home/karma/auxiliary/lazy.hpp>
0019 #include <boost/spirit/home/support/unused.hpp>
0020 #include <boost/spirit/home/support/common_terminals.hpp>
0021 #include <boost/spirit/home/support/has_semantic_action.hpp>
0022 #include <boost/spirit/home/support/handles_container.hpp>
0023 #include <boost/spirit/home/karma/detail/attributes.hpp>
0024 #include <boost/spirit/home/support/info.hpp>
0025 
0026 namespace boost { namespace spirit
0027 {
0028     ///////////////////////////////////////////////////////////////////////////
0029     // Enablers
0030     ///////////////////////////////////////////////////////////////////////////
0031     template <>
0032     struct use_directive<karma::domain, tag::verbatim>   // enables verbatim[]
0033       : mpl::true_ {};
0034 
0035 }}
0036 
0037 namespace boost { namespace spirit { namespace karma
0038 {
0039 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
0040     using spirit::verbatim;
0041 #endif
0042     using spirit::verbatim_type;
0043 
0044     ///////////////////////////////////////////////////////////////////////////
0045     //  The verbatim generator is used for verbatim[...] directives.
0046     ///////////////////////////////////////////////////////////////////////////
0047     template <typename Subject>
0048     struct verbatim_generator : unary_generator<verbatim_generator<Subject> >
0049     {
0050         typedef Subject subject_type;
0051         typedef typename subject_type::properties properties;
0052 
0053         template <typename Context, typename Iterator>
0054         struct attribute
0055           : traits::attribute_of<subject_type, Context, Iterator>
0056         {};
0057 
0058         verbatim_generator(Subject const& subject)
0059           : subject(subject) {}
0060 
0061         template <typename OutputIterator, typename Context, typename Delimiter
0062           , typename Attribute>
0063         bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
0064           , Attribute const& attr) const
0065         {
0066             //  the verbatim generator simply dispatches to the embedded 
0067             //  generator while supplying unused_delimiter as the new delimiter
0068             //  to avoid delimiting down the generator stream
0069             typedef detail::unused_delimiter<Delimiter> unused_delimiter;
0070 
0071             return subject.generate(sink, ctx, unused_delimiter(d), attr) &&
0072                    karma::delimit_out(sink, d);     // always do post-delimiting 
0073         }
0074 
0075         template <typename Context>
0076         info what(Context& context) const
0077         {
0078             return info("verbatim", subject.what(context));
0079         }
0080 
0081         Subject subject;
0082     };
0083 
0084     ///////////////////////////////////////////////////////////////////////////
0085     // Generator generators: make_xxx function (objects)
0086     ///////////////////////////////////////////////////////////////////////////
0087     template <typename Subject, typename Modifiers>
0088     struct make_directive<tag::verbatim, Subject, Modifiers>
0089     {
0090         typedef verbatim_generator<Subject> result_type;
0091         result_type operator()(unused_type, Subject const& subject, unused_type) const
0092         {
0093             return result_type(subject);
0094         }
0095     };
0096 
0097 }}}
0098 
0099 namespace boost { namespace spirit { namespace traits
0100 {
0101     ///////////////////////////////////////////////////////////////////////////
0102     template <typename Subject>
0103     struct has_semantic_action<karma::verbatim_generator<Subject> >
0104       : unary_has_semantic_action<Subject> {};
0105 
0106     ///////////////////////////////////////////////////////////////////////////
0107     template <typename Subject, typename Attribute, typename Context
0108         , typename Iterator>
0109     struct handles_container<karma::verbatim_generator<Subject>, Attribute
0110         , Context, Iterator>
0111       : unary_handles_container<Subject, Attribute, Context, Iterator> {};
0112 }}}
0113 
0114 #endif