Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63755 - trunk/libs/spirit/example/qi
From: hartmut.kaiser_at_[hidden]
Date: 2010-07-08 14:11:42


Author: hkaiser
Date: 2010-07-08 14:11:42 EDT (Thu, 08 Jul 2010)
New Revision: 63755
URL: http://svn.boost.org/trac/boost/changeset/63755

Log:
Spirit: Fixing Qi example for ggc
Text files modified:
   trunk/libs/spirit/example/qi/boost_array.cpp | 19 ++++++++++---------
   1 files changed, 10 insertions(+), 9 deletions(-)

Modified: trunk/libs/spirit/example/qi/boost_array.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/boost_array.cpp (original)
+++ trunk/libs/spirit/example/qi/boost_array.cpp 2010-07-08 14:11:42 EDT (Thu, 08 Jul 2010)
@@ -32,14 +32,15 @@
               : arr_(arr), current_(0) {}
 
             // expose a push_back function compatible with std containers
- void push_back(typename array_type::value_type const& val)
+ bool push_back(typename array_type::value_type const& val)
             {
                 // if the array is full, we need to bail out
- // there is currently no other way of making the parsing fail
+ // returning false will fail the parse
                 if (current_ >= N)
- boost::throw_exception(std::runtime_error("too bad..."));
- else
- arr_[current_++] = val;
+ return false;
+
+ arr_[current_++] = val;
+ return true;
             }
 
             array_type& arr_;
@@ -86,10 +87,10 @@
     struct push_back_container<
       client::detail::adapt_array<boost::array<T, N> >, T>
     {
- static void call(client::detail::adapt_array<boost::array<T, N> >& c
+ static bool call(client::detail::adapt_array<boost::array<T, N> >& c
           , T const& val)
         {
- c.push_back(val);
+ return c.push_back(val);
         }
     };
 }}}
@@ -108,8 +109,8 @@
 
     qi::rule<iterator_type, adapted_type(), ascii::space_type> r = *qi::int_;
 
- bool result = qi::phrase_parse(iter, end, r, ascii::space
- , client::adapt_array(arr));
+ adapted_type attr = client::adapt_array(arr);
+ bool result = qi::phrase_parse(iter, end, r, ascii::space, attr);
 
     if (result)
         std::cout << "Parsed: " << arr[0] << ", " << arr[1] << std::endl;


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