|
Boost : |
Subject: Re: [boost] property_tree iterators
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2009-05-13 03:18:37
On Tue, 12 May 2009 17:25:54 -0700, Chris Meyer
<cmeyer1969+boost_at_[hidden]> wrote:
>
> Perhaps there should be a templatized member function which uses the
> translator to automatically iterate all values of a particular key and
> have it converted to the desired data type.
>
> Then I could use something like:
>
> BOOST_FOREACH(MyType myvar, pt.get_all<MyType>(key))
> {
> doSomething(myvar);
> }
>
> Is this possible? Or is there something I'm missing from the existing
> API that allows me to do this?
Nothing in the existing API, although it is possible. However, I feel that
this would be more suited for a generic iterator/range adaptor library
instead of being embedded in the core interface. The new RangeEx library, I
believe, should help you there. You can take the full range of children
(actually, I plan to add iteration over the children with a given key),
filter on the key, then add a transform iterator that extracts and converts
the value.
Sebastian
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk