Boost logo

Boost Users :

From: Baranowski, Daniel (dbaranowski_at_[hidden])
Date: 2007-07-24 13:29:59


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

 

**********************************************************************************************
Disclaimer - This email and any files transmitted with it are proprietary and may contain privileged or copyright information. You must not present this message to another party without
gaining permission from the sender. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify
us. If you have received this message in error, please notify the sender immediately, and delete this email from your system. We do not guarantee that this material is free from viruses or any
other defects although due care has been taken to minimize the risk. eSafe scanned this email for viruses, vandals and malicious contentAny views expressed in this message are those of
the individual sender, except where the sender specifically states them to be the views of LSI.
**********************************************************************************************



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net