In a config like below; is there a way to handle individual sections.
I am looking for a way to validate individual “server” sections below, in a reliable manner.
[basic]
number_of_servers=3
[server]
ip=10.20.30.40
password=sdfslkhf
[server]
ip=10.20.30.41
password=sdfslkhf
[server]
ip=10.20.30.42
password=sdfslkhf
[server]
password=sdfslkhf
[server]
ip=10.20.30.42
When using
boost::program_optionsto parse a INI file, the option names must be prefixed by their enclosing section names.In other words, sections are part of the option ‘identifier’, but I don’t think you have a way to identify to which section a given
server.ipvariable belongs (and thus, which is the associatedserver.password).I think you should consider Boost.PropertyTree (which also supports INI file parsing) for this task.