Re: [boost] API Review request: XML API for C++, second round
by Hamish Mackenzie other posts by this author
Jun 26 2003 8:00PM messages near this date
Re: [boost] API Review request: XML API for C++, second round
|
Re: [boost] API Review request: XML API for C++, second round
On Thu, 2003-06-26 at 19:51, Stefan Seefeld wrote:
> Hamish Mackenzie wrote:
>
> >>>>And I don't use a 'document' class, as that is managed implicitely
> >>>>by my dom::document_ptr:
> >>>>
> >>>>dom::document_ptr document; // create new document;
> >>>>dom::document_ptr doc(document); // create second reference to it
> >>>>dom::document_ptr doc2 = document.clone(); // clone it, i.e. make deep
> >>>> copy
> >>>
> >>>
> >>>This is not consistent with the standard library or C++ in general. It
> >>>will seem strange that the pointer class
> >>>1) Does not require dereferencing
> >>
> >>would you say the same if the class name was spelled 'document_ref'
> >>instead ?
> >
> >
> > 1 & 4 would be ok, but 3 would stand and having an 'operator bool' would
> > be added to the list.
> >
> >
> >>>3) Has a constructor such as document_ptr( "config.xml" )
> >>>4) Has member functions such as write_to_file
> >>>
> >>>The alternative would allow both...
> >>>
> >>>boost::shared_ptr< dom::document > doc( new dom::document() );
> >>>boost::shared_ptr< dom::document > doc1( doc );
> >>>dom::document doc2( *doc1 );
> >>>
> >>>and if the 'doc1' reference was non-owning...
> >>>
> >>>dom::document doc(); // Create new doc
> >>>dom::document & doc1( doc ); // Second reference
> >>>dom::document doc2( doc1 ); // Deep copy
> >>
> >>right, but given such an approach, what would nodes return in their
> >>'parent()' method ?
> >
> >
> > The parent is always an element (is that right?) so it would return
> > element_ptr or element_ref.
>
> yes. Sorry, I meant to ask what 'document()' would return.
Assuming xmlNode::doc cannot be null it would return document_ref.
You might be worried about...
dom::document dom;
assert( &dom.root().document() == &dom );
I think this can work be made to work with
bool operator ==( document * p1, document_ref * p2 )
{
return p1-> raw_ == p2->raw_;
}
bool operator ==( document_ref * p1, document * p2 )
{
return p1-> raw_ == p2->raw_;
}
etc.
--
Hamish Mackenzie <hamish@[...].uk>
_______________________________________________
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
|