Boost logo

Boost :

From: Marcin Kalicinski (kalita_at_[hidden])
Date: 2006-04-21 19:21:51


> My vote on the current property_tree submission is NO. I think it could be
> re-submitted in the future given a clear rationale accurately stating:
>
> - it's intended use
> - a comparison with similar libraries (have you looked at McObject's
> ExtremeDb as one example)
> - why/why not it's not based on boost.graph libray as a
> Directed-Acyclic-Graph

I believe this rather belongs to a domain of implementation details. What
difference would there be for the users? I have a clear vision of ptree, and
this is std container + extra member functions to make access a snap. I
would not like to expose any boost.graph interface anyway.

> - why would I not just use map< vector<string>, data > along with
> upper/lower bound

Hmm. I think I have an answer below:

#include <map>
#include <string>
#include <vector>
#include <sstream>

// I want to extract an int from some config file
int i;

// That's what I've got to do:

typedef std::map< std::vector<std::string>, std::string > Container;
Container container;
read_xml(..., container); // Note this must be defined somewhere anyway
std::vector<std::string> path;
path.push_back("some");
path.push_back("arbitrarily");
path.push_back("long");
path.push_back("path");
Container::const_iterator it = container.find(path); // A very inefficient
lookup
if (it != container.end())
{
    std::ostringstream out_stream;
    out_stream << it->second;
    std::istringstream in_stream(out_stream.str());
    in_stream >> i; // Finally got it!
}
else
  throw ...

Not a pretty sight, is it? I'd rather download TinyXML. Note that it already
assumes there are parsers implemented somewhere else, which create that
monstrous map. The map solution also does not let you manipulate the
hierarchy in memory - map is a linear structure even though it is internally
implemented as a tree.

I believe any attempt to make the above shorter and more manageable leads
just towards implementing another version of property_tree.

Best regards,
Marcin


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