Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67696 - trunk/boost/spirit/home/support/utree
From: hartmut.kaiser_at_[hidden]
Date: 2011-01-05 18:31:39


Author: hkaiser
Date: 2011-01-05 18:31:39 EST (Wed, 05 Jan 2011)
New Revision: 67696
URL: http://svn.boost.org/trac/boost/changeset/67696

Log:
Spirit: utree: including ranges and references into list handling
Text files modified:
   trunk/boost/spirit/home/support/utree/utree_traits.hpp | 28 ++++++++++++++++++++++++----
   1 files changed, 24 insertions(+), 4 deletions(-)

Modified: trunk/boost/spirit/home/support/utree/utree_traits.hpp
==============================================================================
--- trunk/boost/spirit/home/support/utree/utree_traits.hpp (original)
+++ trunk/boost/spirit/home/support/utree/utree_traits.hpp 2011-01-05 18:31:39 EST (Wed, 05 Jan 2011)
@@ -41,6 +41,26 @@
 ///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace traits
 {
+ namespace detail
+ {
+ bool is_list(utree const& ut)
+ {
+ switch (traits::which(ut))
+ {
+ case utree_type::reference_type:
+ return is_list(ut.deref());
+
+ case utree_type::list_type:
+ case utree_type::range_type:
+ return true;
+
+ default:
+ break;
+ }
+ return false;
+ }
+ }
+
     // this specialization tells Spirit how to extract the type of the value
     // stored in the given utree node
     template <>
@@ -194,7 +214,7 @@
             if (attr.empty()) {
                 attr = val;
             }
- else if (traits::which(val) == utree_type::list_type) {
+ else if (detail::is_list(val)) {
                 typedef utree::const_iterator iterator_type;
 
                 iterator_type end = traits::end(val);
@@ -461,7 +481,7 @@
     {
         static void call(utree& ut)
         {
- if (traits::which(ut) != utree_type::list_type)
+ if (!detail::is_list(ut))
                 ut = empty_list;
         }
     };
@@ -858,7 +878,7 @@
         template <typename T>
         inline T get_or_deref(utree const& t)
         {
- if (traits::which(t) == utree_type::list_type)
+ if (detail::is_list(t))
                 return boost::get<T>(t.front());
             return boost::get<T>(t);
         }
@@ -1084,7 +1104,7 @@
         typedef utree const& type;
         static utree const& pre(utree const& val)
         {
- if (traits::which(val) == utree_type::list_type && 1 == val.size())
+ if (detail::is_list(val) && 1 == val.size())
                 return val.front();
             return val;
         }


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