|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69289 - branches/quickbook-filenames/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-02-25 18:06:42
Author: danieljames
Date: 2011-02-25 18:06:41 EST (Fri, 25 Feb 2011)
New Revision: 69289
URL: http://svn.boost.org/trac/boost/changeset/69289
Log:
Consume values when iterating over a consumer.
Text files modified:
branches/quickbook-filenames/tools/quickbook/src/actions.cpp | 12 +++++++++++-
branches/quickbook-filenames/tools/quickbook/src/values.hpp | 33 +++++++++++++++++++++++++++------
2 files changed, 38 insertions(+), 7 deletions(-)
Modified: branches/quickbook-filenames/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions.cpp 2011-02-25 18:06:41 EST (Fri, 25 Feb 2011)
@@ -637,6 +637,8 @@
<< "Duplicate image attribute: " << name.get_quickbook() << std::endl;
}
}
+
+ values.finish();
// Find the file basename and extension.
//
@@ -1056,6 +1058,8 @@
arg.get_tag() == template_tags::block
));
}
+
+ values.finish();
++actions.template_depth;
if (actions.template_depth > actions.max_template_depth)
@@ -1290,6 +1294,8 @@
}
actions.out << "</variablelist>\n";
+
+ values.finish();
}
void table_action(quickbook::actions& actions, value table)
@@ -1323,10 +1329,12 @@
int row_count = 0;
int span_count = 0;
- BOOST_FOREACH(value row, values) {
+ value_consumer lookahead = values;
+ BOOST_FOREACH(value row, lookahead) {
++row_count;
span_count = boost::distance(row);
}
+ lookahead.finish();
if (has_title)
{
@@ -1366,6 +1374,8 @@
}
actions.out << end_row_;
}
+
+ values.finish();
actions.out << "</tbody>\n"
<< "</tgroup>\n";
Modified: branches/quickbook-filenames/tools/quickbook/src/values.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/values.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/values.hpp 2011-02-25 18:06:41 EST (Fri, 25 Feb 2011)
@@ -15,6 +15,7 @@
#include <string>
#include <cassert>
#include <boost/scoped_ptr.hpp>
+#include <boost/iterator/iterator_traits.hpp>
#include "fwd.hpp"
namespace quickbook
@@ -129,6 +130,7 @@
public:
explicit value_proxy(value_node* base) : value_base(base) {}
value_proxy* operator->() { return this; }
+ value_ref operator*() const { return value_ref(value_); }
};
////////////////////////////////////////////////////////////////////////
@@ -263,8 +265,27 @@
class value_consumer {
public:
- typedef value::iterator iterator;
- typedef value::iterator const_iterator;
+ class iterator
+ : public boost::input_iterator_helper<iterator,
+ boost::iterator_value<value::iterator>::type,
+ boost::iterator_difference<value::iterator>::type,
+ boost::iterator_pointer<value::iterator>::type,
+ boost::iterator_reference<value::iterator>::type>
+ {
+ public:
+ iterator();
+ explicit iterator(value::iterator* p) : ptr_(p) {}
+ friend bool operator==(iterator x, iterator y)
+ { return *x.ptr_ == *y.ptr_; }
+ iterator& operator++() { ++*ptr_; return *this; }
+ reference operator*() const { return **ptr_; }
+ pointer operator->() const { return ptr_->operator->(); }
+ private:
+ value::iterator* ptr_;
+ };
+
+
+ typedef iterator const_iterator;
typedef iterator::reference reference;
value_consumer(value const& x)
@@ -323,14 +344,14 @@
void finish() const
{
- assert(pos_ == end_);
+ assert(pos_ == end_);
}
- iterator begin() const { return pos_; }
- iterator end() const { return end_; }
+ iterator begin() { return iterator(&pos_); }
+ iterator end() { return iterator(&end_); }
private:
value list_;
- iterator pos_, end_;
+ value::iterator pos_, end_;
};
}
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