Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66937 - in trunk/boost/spirit/home/support/utree: . detail
From: hartmut.kaiser_at_[hidden]
Date: 2010-11-30 18:39:20


Author: hkaiser
Date: 2010-11-30 18:39:12 EST (Tue, 30 Nov 2010)
New Revision: 66937
URL: http://svn.boost.org/trac/boost/changeset/66937

Log:
Spirit: more utree fixes for better integration with Qi
Text files modified:
   trunk/boost/spirit/home/support/utree/detail/utree_detail2.hpp | 9 +++++++++
   trunk/boost/spirit/home/support/utree/utree.hpp | 1 +
   trunk/boost/spirit/home/support/utree/utree_traits.hpp | 21 ++++++++++++++++-----
   3 files changed, 26 insertions(+), 5 deletions(-)

Modified: trunk/boost/spirit/home/support/utree/detail/utree_detail2.hpp
==============================================================================
--- trunk/boost/spirit/home/support/utree/detail/utree_detail2.hpp (original)
+++ trunk/boost/spirit/home/support/utree/detail/utree_detail2.hpp 2010-11-30 18:39:12 EST (Tue, 30 Nov 2010)
@@ -764,6 +764,15 @@
         return *this;
     }
 
+ inline utree& utree::operator=(char c)
+ {
+ // char constructs a single element string
+ free();
+ s.construct(&c, &c+1);
+ set_type(type::string_type);
+ return *this;
+ }
+
     inline utree& utree::operator=(unsigned int i_)
     {
         free();

Modified: trunk/boost/spirit/home/support/utree/utree.hpp
==============================================================================
--- trunk/boost/spirit/home/support/utree/utree.hpp (original)
+++ trunk/boost/spirit/home/support/utree/utree.hpp 2010-11-30 18:39:12 EST (Tue, 30 Nov 2010)
@@ -297,6 +297,7 @@
 
         utree& operator=(utree const& other);
         utree& operator=(bool b);
+ utree& operator=(char c);
         utree& operator=(unsigned int i);
         utree& operator=(int i);
         utree& operator=(double d);

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 2010-11-30 18:39:12 EST (Tue, 30 Nov 2010)
@@ -64,15 +64,26 @@
     ///////////////////////////////////////////////////////////////////////////
     // this specialization tells Spirit.Qi to allow assignment to an utree from
     // a STL container
- template <typename Container>
- struct assign_to_attribute_from_value<utree, Container
- , typename enable_if<is_container<Container> >::type>
+ template <typename Attribute>
+ struct assign_to_attribute_from_value<utree, Attribute>
     {
- static void
- call(Container const& val, utree& attr)
+ static void call(Attribute const& val, utree& attr, mpl::false_)
+ {
+ if (attr.empty())
+ attr = val;
+ else
+ attr.push_back(val); // implicitly converts utree to a list
+ }
+
+ static void call(Attribute const& val, utree& attr, mpl::true_)
         {
             attr = make_iterator_range(traits::begin(val), traits::end(val));
         }
+
+ static void call(Attribute const& val, utree& attr)
+ {
+ call(val, attr, is_container<Attribute>());
+ }
     };
 
     ///////////////////////////////////////////////////////////////////////////


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