
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@example.com // 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).
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
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. the get_default function. Schemas for PTree could be designed as a layer around PTree though. Sebastian