ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
[boost] Re: API Review request: XML API for C++, second round
by Anthony Williams other posts by this author
Jun 27 2003 8:09AM messages near this date
Re: [boost] Re: API Review request: XML API for C++, second round | Re: [boost] Re: API Review request: XML API for C++, second round
Stefan Seefeld <seefeld@[...].ca>  writes:

>  Hamish Mackenzie wrote:
>  
>  > dom::document doc;
>  > dom::document_ref doc2( doc.root().document() );
>  > assert( &doc2 == &doc );
>  > and...
>  > assert( doc2 == doc );
>  > Can be implemented but ideally it would compare all the nodes in the
>  > document.
>  
>  well, that's different. Do you want to know whether both documents are
>  equal, or whether they are identical, i.e. whether both references point to
>  the same document ?
>  
>  Hmm, just to check whether we are still talking about the same thing here:
>  do we agree that there can't be a 'node' type, i.e. just a
>  'node_ref'/'node_ptr' ?

You mean: have "node" as an abstract class, so you can't have any objects of
that type, but you can have pointers and references? Sounds good.

What's wrong with just having boost::shared_ptr<Document>  and
boost::shared_ptr<Node> , boost::shared_ptr<Element> ?

You could have each node store a boost::weak_ptr<Element>  pointing to its
parent, which is converted to a boost::shared_ptr<Element>  when you ask for
it. That way, a child doesn't keep its parent alive (though parents should
keep their children alive), but you can still traverse up the tree if you
like.

You could do the same for documents --- the document holds a shared_ptr to the
root element, and so keeps the whole tree alive. Each element holds a weak_ptr
to the document, so you can retrieve the document from it, but it doesn't keep
it alive. Consequently, if you erase an element from the document, but you
still have a pointer to it, then the element itself is OK, but it will then
die when your pointer goes out of scope. Also, if the document goes out of
scope, then your element is still OK, but is no longer associated with a
document.

Anthony
-- 
Anthony Williams
Senior Software Engineer, Beran Instruments Ltd.
Remove NOSPAM when replying, for timely response.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Stefan Seefeld
Anthony Williams
Hamish Mackenzie
Stefan Seefeld
Anthony Williams
Hamish Mackenzie
Bohdan
Stefan Seefeld
Hamish Mackenzie
Stefan Seefeld
Hamish Mackenzie
Hamish Mackenzie
Stefan Seefeld
Hamish Mackenzie
Stefan Seefeld
Hamish Mackenzie
Stefan Seefeld
Hamish Mackenzie
Bohdan
Stefan Seefeld
Stefan Seefeld
Hamish Mackenzie
Stefan Seefeld
Hamish Mackenzie
Hamish Mackenzie

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved