[Libxmlplusplus-general] Re: [xml] Re: [gnomemm] ANNOUNCE: libxml++ is now sane.



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.

>
> Stefan
>

Christophe





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