Boost logo

Boost :

From: Matias Capeletto (matias.capeletto_at_[hidden])
Date: 2006-04-22 15:22:48

On 4/22/06, Marcin Kalicinski <kalita_at_[hidden]> wrote:

> I created a brief summary of enhancements/changes to property_tree which
> were proposed so far.
> I hope this will serve as a basis for continued discussion.

Very nice to have all the proposal together. Maybe we can continue in
this thread with ptree interface/implementation details. The principal
thread is dominated by the pt/po/s11n discussion and is very dificult
to track anything else.

> 5. Add possibility to specify names of "special" keys in parsers (<xmlattr>,
> <xmlcomment> etc.). Add whitespace-handling flags to XML reader.

Following this from the point of view of the ptree interface, i read a
post that says it didnt like the "xxx.<xmlattr>.yyy" sintaxis. I think
that whit the path class in place now we have the possibility to do, (
if we can make simple to create different path specialization
ortogonal to the ptree ):

xml_path p;

data.put( p / "debug" / "info" + "attname" , 10 );
// Ovewrittes operator+ for attributtes, this will be equal to write:
// p / "debug" / "info" / "<xmlattr>" / "attname"
// The + selection has the advantage that it cannot be used in the middle
// of the path construction expression, this make sence for attributes.

data.put( p / "debug" / "info" / attr("attname") , 10 );
// Other approach... i like the first one more.

The commentaries can be worked out to.

> 6. Add "set" function. "set" will work in a similar fashion to put, except
> that it will always replace existing key if it exists. Extra boolean
> parameter to put functions will be gone. Alternative approach is to replace
> bool parameter to put with enum to improve readability.

I like the set function more, much less to write and the same readability.

> 8. Add support for array-style indexing in paths. This will probably work
> well with #1.

Other thoughts in this point. I have realized that in many of the xml
formats i used there are repetead tags to represent somenthing and the
ordering is not important. an example

    <log> .... </log>
    <log> .... </log>
        <time> 10:02 </time>
        <text> error1 </text>
        <checked> false </checked>
    <log> .... </log>
    <log> .... </log>

Sometimes it will be nice to modified the checked field of the log that have
text error1. This can be done fairly simple with the actual interface
of ptree, i think that in no more that a bunch of lines. But if this
kind of task have to be repeated frequently will be nice to have an
easy way to deal with it. For example if we permitted indexing in the
paths, we can think that the path to the correct log is somewhat
indexed by text subfield, so this to lines will produce the same

data.set(p / "log"%where("text",bind(equal,_1,"error1")) / "checked" , "true" );
data.set(p / "log"%3 / "checked", "true" );

The where statement takes a "path", and a functor that have defined
bool operator()(ptree::data &), this mechanism can be used for complex
indexing. I feel it like a very nice to have feature that can be implemented
too without affecting the actual easy to use interface.

> Additionally there were proposals to use runtime polymorphism to distinguish
> between leaf and branch nodes. I think this idea strays so far from current
> implementation/interface of the library, that it is not feasible to do.

I'm agree with you.

Boost list run by bdawes at, gregod at, cpdaniel at, john at