Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60637 - sandbox/xml/boost/xml/dom
From: seefeld_at_[hidden]
Date: 2010-03-15 21:47:45


Author: stefan
Date: 2010-03-15 21:47:44 EDT (Mon, 15 Mar 2010)
New Revision: 60637
URL: http://svn.boost.org/trac/boost/changeset/60637

Log:
Give node_set move-semantics.
Text files modified:
   sandbox/xml/boost/xml/dom/detail.hpp | 6 ++++++
   sandbox/xml/boost/xml/dom/node_set.hpp | 17 +++++++++++++++--
   2 files changed, 21 insertions(+), 2 deletions(-)

Modified: sandbox/xml/boost/xml/dom/detail.hpp
==============================================================================
--- sandbox/xml/boost/xml/dom/detail.hpp (original)
+++ sandbox/xml/boost/xml/dom/detail.hpp 2010-03-15 21:47:44 EDT (Mon, 15 Mar 2010)
@@ -79,6 +79,12 @@
   using accessor::impl;
   T &impl() { return this->impl_;}
   T const impl() const { return this->impl_;}
+ T release()
+ {
+ T tmp = impl_;
+ impl_ = 0;
+ return tmp;
+ }
 private:
   T impl_;
 };

Modified: sandbox/xml/boost/xml/dom/node_set.hpp
==============================================================================
--- sandbox/xml/boost/xml/dom/node_set.hpp (original)
+++ sandbox/xml/boost/xml/dom/node_set.hpp 2010-03-15 21:47:44 EDT (Mon, 15 Mar 2010)
@@ -11,6 +11,16 @@
 namespace dom
 {
 
+namespace detail
+{
+template<typename S>
+struct node_set_ref
+{
+ explicit node_set_ref(xmlNodeSet *p): ptr(p) {}
+ xmlNodeSet *ptr;
+};
+}
+
 template <typename S>
 class node_set : public detail::wrapper<xmlNodeSet*>
 {
@@ -18,8 +28,11 @@
 public:
   class iterator;
 
- ~node_set() { xmlXPathFreeNodeSet(this->impl());}
-
+ node_set(node_set &s) : detail::wrapper<xmlNodeSet*>(s.release()) {}
+ node_set(detail::node_set_ref<S> ref) : detail::wrapper<xmlNodeSet*>(ref.ptr) {}
+ ~node_set() { if (this->impl()) xmlXPathFreeNodeSet(this->impl());}
+ operator detail::node_set_ref<S>() throw() { return detail::node_set_ref<S>(this->release());}
+
   size_t size() const { return this->impl() ? this->impl()->nodeNr : 0;}
   node_ptr<node<S> > operator[] (size_t i)
   {


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