Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60195 - trunk/boost/spirit/home/support/iterators/detail
From: hartmut.kaiser_at_[hidden]
Date: 2010-03-05 11:56:12


Author: hkaiser
Date: 2010-03-05 11:56:12 EST (Fri, 05 Mar 2010)
New Revision: 60195
URL: http://svn.boost.org/trac/boost/changeset/60195

Log:
Spirit: adjustments to buffering_input_iterator
Text files modified:
   trunk/boost/spirit/home/support/iterators/detail/buffering_input_iterator_policy.hpp | 29 ++++++++++++++++++++---------
   1 files changed, 20 insertions(+), 9 deletions(-)

Modified: trunk/boost/spirit/home/support/iterators/detail/buffering_input_iterator_policy.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/detail/buffering_input_iterator_policy.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/detail/buffering_input_iterator_policy.hpp 2010-03-05 11:56:12 EST (Fri, 05 Mar 2010)
@@ -66,17 +66,14 @@
             template <typename ValueType, typename MultiPass>
             static ValueType& get_input(MultiPass& mp)
             {
- value_type& curtok = mp.shared()->curtok;
- if (!input_is_valid(mp, curtok))
- curtok = *mp.shared()->input_++;
- return curtok;
+ return mp.shared()->get_input();
             }
 
             template <typename MultiPass>
             static void advance_input(MultiPass& mp)
             {
                 BOOST_ASSERT(0 != mp.shared());
- mp.shared()->curtok = *mp.shared()->input_++;
+ mp.shared()->advance_input();
             }
 
             // test, whether we reached the end of the underlying stream
@@ -90,8 +87,7 @@
             template <typename MultiPass>
             static bool input_is_valid(MultiPass const& mp, value_type const& t)
             {
- using namespace input_iterator_is_valid_test_;
- return token_is_valid(t);
+ return mp.shared()->input_is_valid_;
             }
 
             // no unique data elements
@@ -105,10 +101,25 @@
                 typename boost::detail::iterator_traits<T>::value_type
             result_type;
 
- explicit shared(T const& input) : input_(input), curtok(0) {}
+ explicit shared(T const& input)
+ : input_(input), curtok_(0), input_is_valid_(false) {}
+
+ void advance_input()
+ {
+ curtok_ = *input_++;
+ input_is_valid_ = true;
+ }
+
+ result_type& get_input()
+ {
+ if (!input_is_valid_)
+ advance_input();
+ return curtok_;
+ }
 
             T input_;
- result_type curtok;
+ result_type curtok_;
+ bool input_is_valid_;
         };
     };
 


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