Re: [Libxmlplusplus-general] parametrizing libxml++ for the character /string type



Murray Cumming wrote:

reinterpret_cast<Node *>(this->_impl->children->_private)


It should probably be a static_cast<> if _private is a void*, but it's
not a big deal.

hmm, does this make a difference for casts from 'void *' ? There is no
offset to adjust...

So, we create new xmlpp::Nodes to wrap each xmlNode, but when do those
xmlpp::Nodes get deleted?

That's indeed one of those questions that are still a bit unclear. I see
two possibilities:

* parent xmlpp::Node objects explicitely destroy their child objects

or

* xmlpp::Node objects are owned by their libxml2 counterparts. This can
  work thanks to a recent addition from Daniel: since libxml2 2.5.1 you
  can install callbacks that are called on libxml2 object
  creation/deletion, so we can manage the _private members there

I tend to think the second is much more clean and consistent with the
rest of the proposed change. However, Daniel seemed not 100 % confident
that this works in all cases. Possibly because we'd be the first to use
(and stress-test) that feature. We'll have to try it out, I guess.

The tricky point is, as said earlier, ownership management. libxml2's nodes
are owned by their parent nodes (and ultimately by the enclosing document),
not by the libxml++ wrapper object. We need to work out how transfer of ownership
should happen when a node is unlinked from its document / parent node.


Is there any way to get notification of this?

yes, see above.

Regards,
		Stefan

PS: the patch I sent in yesterday doesn't cover all objects. After having sent in the patch I continued with more objects, notably adding
a 'Document' type. I'll wait with these patches as that'll involve some
more changes, possibly also on the API level.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]