|
Boost : |
From: Hamish Mackenzie (hamish_at_[hidden])
Date: 2003-06-26 09:44:43
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_at_[hidden]>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk