Back to home page

EIC code displayed by LXR

 
 

    


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

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_NO_DELIMIT_JAN_19_2010_0920AM)
0007 #define BOOST_SPIRIT_KARMA_NO_DELIMIT_JAN_19_2010_0920AM
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/auxiliary/lazy.hpp>
0018 #include <boost/spirit/home/support/unused.hpp>
0019 #include <boost/spirit/home/support/common_terminals.hpp>
0020 #include <boost/spirit/home/support/has_semantic_action.hpp>
0021 #include <boost/spirit/home/support/handles_container.hpp>
0022 #include <boost/spirit/home/karma/detail/attributes.hpp>
0023 #include <boost/spirit/home/support/info.hpp>
0024 
0025 namespace boost { namespace spirit
0026 {
0027     ///////////////////////////////////////////////////////////////////////////
0028     // Enablers
0029     ///////////////////////////////////////////////////////////////////////////
0030     template <>
0031     struct use_directive<karma::domain, tag::no_delimit>   // enables no_delimit[]
0032       : mpl::true_ {};
0033 
0034 }}
0035 
0036 namespace boost { namespace spirit { namespace karma
0037 {
0038 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
0039     using spirit::no_delimit;
0040 #endif
0041     using spirit::no_delimit_type;
0042 
0043     ///////////////////////////////////////////////////////////////////////////
0044     //  The no_delimit generator is used for no_delimit[...] directives.
0045     ///////////////////////////////////////////////////////////////////////////
0046     template <typename Subject>
0047     struct no_delimit_generator 
0048       : unary_generator<no_delimit_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         no_delimit_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 no_delimit 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             // the difference to verbatim[] is that this does not post-delimit
0072             return subject.generate(sink, ctx, unused_delimiter(d), attr);
0073         }
0074 
0075         template <typename Context>
0076         info what(Context& context) const
0077         {
0078             return info("no_delimit", 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::no_delimit, Subject, Modifiers>
0089     {
0090         typedef no_delimit_generator<Subject> result_type;
0091 
0092         result_type 
0093         operator()(unused_type, Subject const& subject, unused_type) const
0094         {
0095             return result_type(subject);
0096         }
0097     };
0098 
0099 }}}
0100 
0101 namespace boost { namespace spirit { namespace traits
0102 {
0103     ///////////////////////////////////////////////////////////////////////////
0104     template <typename Subject>
0105     struct has_semantic_action<karma::no_delimit_generator<Subject> >
0106       : unary_has_semantic_action<Subject> {};
0107 
0108     ///////////////////////////////////////////////////////////////////////////
0109     template <typename Subject, typename Attribute, typename Context
0110         , typename Iterator>
0111     struct handles_container<karma::no_delimit_generator<Subject>, Attribute
0112         , Context, Iterator>
0113       : unary_handles_container<Subject, Attribute, Context, Iterator> {};
0114 }}}
0115 
0116 #endif