Boost logo

Boost :

From: Hamish Mackenzie (hamish_at_[hidden])
Date: 2003-06-13 15:02:26


On Fri, 2003-06-13 at 19:39, Reece Dunn wrote:
> >>This would, however, allow the implementation to be adapted to when memory
> >>management needs to be used and to switch between different management
> >>policies for the various implementations.
>
> >Can you elaborate ?
>
> Sure. In the libxml2 versions, nodes are explicitly deleted, and thus do not
> need to be managed, e.g:
> typedef node_impl * node;
>
> If an object requires explicit management, via shared_ptr for example:
> typedef boost::shared_ptr< node_impl > node;
>
> Or, if it is say using a wrapper around an MSXML interface:
> class node: public CComPtr< IXMLDOMNode >{ ... };
>
> The user can thus write:
> boost::xml::dom::node mynode = doc.selectNode( "/h:*[1]" );
>
> without worrying about the underlying representation of
> boost::xml::dom::node.

These are all pointer types though, so node_ptr is perhaps be a better
name.

How do you feel about having a node_reference instead.

// libxml2
class node_reference
{
private:
  xmlNodePtr node_;
};

// MSXML
class node_reference
{
private:
  CComPtr< IXMLDOMNode > node_;
};

boost::xml::dom::node_reference mynode = doc.selectNode( "/h:*[1]" );

A node_reference to an object in the document would only be safe as long
as that node existed in the document.

-- 
Hamish Mackenzie <hamish_at_[hidden]>

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk