Re: [xml] Re: [gnomemm] ANNOUNCE: libxml++ is now sane.
- From: Christophe de Vienne <cdevienne netcourrier com>
- To: Stefan Seefeld <seefeld sympatico ca>
- Cc: libxml-list <xml gnome org>, libxmlplusplus-general lists sourceforge net
- Subject: Re: [xml] Re: [gnomemm] ANNOUNCE: libxml++ is now sane.
- Date: Thu, 21 Nov 2002 00:24:33 +0100
On Jeudi 21 Novembre 2002 00:12, Stefan Seefeld wrote:
Paul Davis wrote:
const Node * add_child (const std::string &name)
Node * add_child (Node *node)
has caused dozens of stupid bugs in my code, because it doesn't make
it clear whether the added child is copied or not (its not).
A good way to make the intention clear would be to pass
'std::auto_ptr<Node>' instead of raw pointers, whenever you want it
to be adopted.
The problem with auto_ptr is that it's absolutely not recommended to use them
inside the STL containers. Another way would be to use
map<std::string, Attribute> instead of map<std::string, Attribute *>
The result is the same, although we'll have to be carefull about how copy
constructors are implemented.
But this will not apply to Node, if we want to implement this :
I, too, have an API enhancement suggestion: Please consider a method
'Node::lookup(const std::string &xpath)' that does an xpath lookup
(surprize !) and returns a NodeSet. I'v written my own C++ wrapper
around libxml2 and this method is incredibly useful in my work...
Once we agree on a name for this method (lookup, find, xpath, evaluate,
evalateXPath... ?), we'll add it.
] [Thread Prev