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
Re: [boost] API Review request: XML API for C++, second round
by Hamish Mackenzie other posts by this author
Jun 26 2003 2:44PM 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
Ok I think I understand the problem now.  What does node-> document()
return and what does it point to???

Well I think as with the node-> parent() it should return a proxy
object.  Something like...

// non owning reference
class document_ref
{
public:
  // Define document related methods here
protected:
  document_ref() : raw_( 0 ) {}
  xmlDoc * raw_;
};

// non owning pointer
class document_ptr
{
public:
  document_ptr( document_ref * );
  document_ref operator *() { return ref_; }
  document_ref * operator -> () { return &ref_; }
private:
  document_ref ref_;
};

// owning object with deep copy
class document : public document_ref
{
public:
  explicit document( const std::string & file );
  document( document_ref source )
  {
    // Deep copy here
  }
  ~document() { xmlFreeDoc( raw_ ); }
};

root-> document() can return document_ptr or document_ref.

>  > value_types could exist but it would require a deep copy to be
>  > consistent.  If you do want to define it then I suggest
>  
>  you mean if I do *not* want to define it ?

Yes, you could
1) define a deep copy value_type
2) typedef void value_type;
3) leave it undefined

>  > Your iterator types look good.  Why is there an extra level of
>  > indirection in basic_element_const_iterator?
>  
>  the const iterator is non-functional right now. I'v been wondering
>  how to provide one. It seems I would need to define a 'const_node_ptr'
>  set of classes.

I think that is right.  I would prefer it to be

typedef node_pointer< node_ref >  node_ptr;
typedef node_pointer< const_node_ref >  const_node_ptr;

In fact you will probably need const_ versions for all your reference,
pointer and iterator types. Though the pointers and iterators should
just be additional instances of template classes.

-- 
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

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