
Thorsten Ottosen wrote:
Matias Capeletto wrote:
If we get the path into ptree we can overload other operator to support this type of path (we can not overload operator[]... because of precedence issues :( someone nows a way we can still use it?, the sintaxis will be very nice. As i see it, the only the choosen operator must have the same priority, see the examples, so we have only have * and % ).
Something like this may work...
ptree data; ptree::path p;
data.put( p / "debug" / "info" / "testfail" , "somefile.hpp" ); data.put( p / "debug" / "info" / "testfail" , "otherfile.hpp" ); data.put( p / "debug" / "info" / "testfail" , "wer.hpp" );
data.set( p / "debug" / "info" / "testfail" %2 , "file.hpp" ); // we use set!
some simple function would allow you to write
data.set( p / "debug" / "info" / "testfail" / at(2) , "file.hpp" );
or we might say
data.set( (p / "debug" / "info" / "testfail")[2] , "file.hpp" );
or perhaps
data.set( p / "debug" / "info" / "testfail[2]" , "file.hpp" );
Exactly! There are many solutions that provide the generality/flexibility while providing ease of use. The library could also provide a function(s) that take a delimited string and return a valid path to encompass the original usage presented by Marcin. Jeff Flinn