Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2006-04-22 12:53:34


This isn't my full review, just a few issues I see. I think this
library has great potential and value, but I'm going to stick to the
issues for now. I posted most of this just before the review, but got no
response:

http://lists.boost.org/Archives/boost/2006/04/103305.php

I see 3 serious issues at this point:

1) Find is under documented / doesn't work for me

     ptree pt;
     read_ini("test.ini", pt);
     ptree::const_iterator ci = pt.find("value2");
     if (ci != pt.end()) {
       std::cout << ci->second.data() << std::endl;
     }

    //test.ini
   [User Data] ; This is a comment
   value1 = v1
   value2 = v2
   date = 2006-Apr-18

I tried various keys in the find including:

     ptree::const_iterator ci = pt.find("User Data.value2");

All returned null iterator. So there are two problems. From the docs
it wasn't clear what syntax to use with find and it doesn't appear to work.

2) Iterators are underspecified

It was totally unclear to me from the docs what the interface to
iterators returned from the interface. I finally found a test or
example and copied.

       std::cout << ci->second.data() << std::endl;

3) Write operations are not 'whitespace' and comment preserving

To me this is a critical point not fulfilled by the library. Most
real-world configuration files have comments. If the application needs
to read/write the files it needs to maintain the comments as human
written. In my experiment if I start with this:

  //test.ini
   [User Data] ; This is a comment
   value1 = v1
   value2 = v2
   date = 2006-Apr-18

After I write it back I get:

   [User Data]
   value1=v1
   value2=v2
   date=2006-Apr-18

I realize that this requirement might increase the resource usage of
property_tree, so I'm fine with this being an optionally enabled feature.

Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk