Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59540 - in trunk/boost/spirit/home/karma: detail directive
From: hartmut.kaiser_at_[hidden]
Date: 2010-02-06 22:56:23


Author: hkaiser
Date: 2010-02-06 22:56:22 EST (Sat, 06 Feb 2010)
New Revision: 59540
URL: http://svn.boost.org/trac/boost/changeset/59540

Log:
Spirit: buffer[buffer[...]] does not result in double buffering anymore
Text files modified:
   trunk/boost/spirit/home/karma/detail/alternative_function.hpp | 15 +++++++++++++++
   trunk/boost/spirit/home/karma/directive/buffer.hpp | 11 +++++++++++
   2 files changed, 26 insertions(+), 0 deletions(-)

Modified: trunk/boost/spirit/home/karma/detail/alternative_function.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/detail/alternative_function.hpp (original)
+++ trunk/boost/spirit/home/karma/detail/alternative_function.hpp 2010-02-06 22:56:22 EST (Sat, 06 Feb 2010)
@@ -12,6 +12,7 @@
 #endif
 
 #include <boost/spirit/home/karma/domain.hpp>
+#include <boost/spirit/home/karma/directive/buffer.hpp>
 #include <boost/spirit/home/support/unused.hpp>
 #include <boost/spirit/home/support/attributes.hpp>
 #include <boost/spirit/home/support/detail/hold_any.hpp>
@@ -240,6 +241,20 @@
             return r;
         }
 
+ // avoid double buffering
+ template <typename Component>
+ bool operator()(buffer_directive<Component> const& component)
+ {
+ typedef typename
+ traits::attribute_of<Component, Context>::type
+ expected_type;
+ typedef alternative_generate<
+ buffer_directive<Component>, Attribute, expected_type>
+ generate;
+
+ return generate::call(component, sink, ctx, delim, attr);
+ }
+
         OutputIterator& sink;
         Context& ctx;
         Delimiter const& delim;

Modified: trunk/boost/spirit/home/karma/directive/buffer.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/directive/buffer.hpp (original)
+++ trunk/boost/spirit/home/karma/directive/buffer.hpp 2010-02-06 22:56:22 EST (Sat, 06 Feb 2010)
@@ -97,6 +97,17 @@
         }
     };
 
+ // make sure buffer[buffer[...]] does not result in double buffering
+ template <typename Subject, typename Modifiers>
+ struct make_directive<tag::buffer, buffer_directive<Subject>, Modifiers>
+ {
+ typedef buffer_directive<Subject> result_type;
+ result_type operator()(unused_type
+ , buffer_directive<Subject> const& subject, unused_type) const
+ {
+ return subject;
+ }
+ };
 }}}
 
 namespace boost { namespace spirit { namespace traits


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk