Re: [libxml++] node iterators



On Fri, Feb 07, 2003 at 10:34:22AM -0500, Stefan Seefeld wrote:

> It seems there are two ways to do this without creating too much
> overhead:
> 
> 1) let the 'Node' object itself act as the container (which it actually
>    is in libxml2), using 'child_iterator' and 'attribute_iterator'.
> 
> 2) provide a thin 'NodeList' interface that provides the STL API. 'Node'
>    would then have two methods 'NodeList get_children()' and
>    'NodeList get_attributes()'.
> 
> 
> 1) is what I currently propose, while 2) is a slight modification of
> what a) exists now and b) Jonathan suggests. The advantages over the
> original suggestion (just using an STL container 'NodeList') is that it
> could avoid unnecessary copying. So, while 2) still uses one (IMO) 
> unnecessary indirection (you have to access the 'children' container
> to iterate it, instead of directly accessing the 'child_iterators')
> It seems to be quite reasonable performance-wise.

I'm now thinking that ForwardContainer migh be a better choice of STL
concept to model, as it has fewer requirements so might be simpler to
implement 1) while still supporting an STL-style interface. This would
mean you can get an iterator from any Node, not just from some container
type.

I'm going to think more about this over the weekend, look at xmlwrapp
again, and maybe look at how some examples of use would differ with the
two proposals.

jon

-- 
"Fanaticism consists in redoubling your efforts when you have forgotten 
 your aims."
	- George Santayana




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