Re: [libxml++] Re: [Libxmlplusplus-general] Node ownership
- From: Stefan Seefeld <seefeld sympatico ca>
- To: libxmlplusplus-general lists sourceforge net
- Subject: Re: [libxml++] Re: [Libxmlplusplus-general] Node ownership
- Date: Thu, 06 Feb 2003 15:11:50 -0500
Murray Cumming wrote:
1) you suggest an additional member: 'owned_by_libxml', which isn't
necessary as you can determine by inspecting the _impl whether it
is linked into a tree.
Yes, that might work, but I'd prefer not to access libxml's private
structures.
what is a private structure ? I agree that we have to be very cautious
to only use things part of the public API. I probably should ask DV
which members of the various structs he considers public and which not.
2) you need an accessible destructor, so you can delete the node
explicitely, after having checked that you are allowed to
if (!node->is_owned_by_libxml()) delete node;
or equivalent. That doesn't look very nice.
Or just assume that you know what you are doing. The existence of an
is_owned_by_libxml() method wouldn't force you to use it.
Yes, but even then I'd prefer to be able to just throw
'invalid_argument' or something, instead of watching the application
crash.
But being able to use the delete operator would be very hacky, because
it implies a circular dependency that you'd need to break out explicitely:
Node::~Node()
{
if (_impl)
{
_impl->private = 0; // make sure this destructor isn't called twice
xmlFreeNode(_impl);
}
}
Stefan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]