Boost logo

Boost :

Subject: Re: [boost] Library for configuration file parsing
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2010-11-26 06:47:32


On 26.11.2010 12:11, Denis Shevchenko wrote:
> This is example of more complex configuration file:
> --------------------------------------------------------------------------------------
>
> /*
> * more_complex.conf
> */
>
> DbName : my_database
> DbHost : localhost
> DbPort : 100
> DbUser : some_user
> DbPassword : some_password
>
> <Server>
> Host : 12.45.46.15 // IP semantic may be
> check.
> Port : 1080 // Value must be
> unsigned integer number.
> Admin/*this is comment with unnecessary info
> asf*/istrator : admin_at_[hidden] // e-mail semantic
> may be check.
>
> StorePath : /some/path // path
> semantic may be check.
>
> <Internal>
> Logfile : /some/path/to/logfile // path
> semantic may be check.
> MaxLogFileSize : 10 MB // size
> semantic may be check, result in bytes.
> </Internal>
>
> ReconnectPeriod : 10 m // time-period semantic may be check,
> result in seconds.
> </Server>
>
> <Plugins>
> plugins : a_plug b_plug
> plugins : c_plug
> plugins : d_plug
> plugins : e_plug
> </Plugins>
> ----------------------------------------------------------------------------------------
>
PropertyTree could support such a format. However, it would not support
schema support for configuration files, e.g. check semantics or
automatically have default values available. It wouldn't be too hard to
write a check for any given tree, though.

>
> I know boost::property_tree, this is very good library, but (imho) it
> is designed specifically to advanced work with XML (though not only
> with him).
No. The PTree XML parser is too basic to claim that it is for advanced
work with XML. There is no support for advanced XML features at all.
> In other words, primaryarea of this library is notwork with
> configuration files(imho).
IMO it is, and since I'm the maintainer, my opinion is not humble. :-)
> I could not find in the documentation (or in examples) of
> boost::property_tree features such as option's default value or
> necessary.
There is no schema definition or validation in PTree. However, there is
the get_default function.
Schemas for PTree could be designed as a layer around PTree though.

Sebastian


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