Hello All!
Is it possible to parse an INI file with the program options
without specifying what is in the INI file first (using options_descriptions)?
I already use the program_options library to handle command
line and config file based options, but what I’m looking for now is a more
traditional ini file interaction. By that I mean where you simply read in the
ini file and then can access the category/entry value with something like:
INIFile
iniFile(“MyINIFile.ini”);
int
myInt = iniFile[“Category”][“EntryName”].get<int>(3);
// 3 is the default if entry not found
In my case, these are options that the user does not need to
know about and can only be specified through the configuration file. Therefore,
much of the data that is in the options_description is redundant.
I’ve been looking around, and it seems that the
parse_config_file() is the standard function to call to parse an INI file,
however, that takes an options_description object as the second parameter.
I did see in boost/program_options/detail/config_file.hpp where
it talks about being able to read standard ini files and how the sections and
entries are accessed. Unfortunately, that’s buried in the “details”
and I don’t see any part of the public interface that would allow me to access
the ini file.
I did read a little about the property_tree library, but that
is only available in CVS and I would prefer to stick with one library to handle
the program’s configuration. Similarly, I have seen plenty of other
config libraries out there, but I would prefer to stick with program_options if
it can do the job.
Thanks for any help!
Regards,
Daniel