Reputation: 18063
We are developing a rather large project in C++, where many components require configuration parameters. We would like to use a central place to configure everything (like a registry), preferably with a nice and simple GUI (e.g. like Firefox's about:config
) and a simple API.
I am pretty sure this that many applications have this kind of problem, but could not find any libraries available that can be readily used for this. Does anyone know of a good (preferably free) library to use for this?
This should work cross platform in Windows and Linux.
Upvotes: 6
Views: 5407
Reputation: 161
I've used libconfig before, works well easy and LGPL. http://www.hyperrealm.com/libconfig/
Upvotes: 3
Reputation: 1448
Try Configurator. There is no GUI, but it's easy-to-use and flexible C++ library for configuration file parsing (from simplest INI to complex files with arbitrary nesting and semantic checking). Header-only and cross-platform. Uses Boost C++ libraries.
See: http://opensource.dshevchenko.biz/configurator
Upvotes: 0
Reputation: 24892
boost::program_options provides unified (and cross platform) support for configuration from command line, environment variables and configuration files. It seems like it ought to scale to multiple bits of a large software system registering an interest in various parameters (e.g option groups). Not much help with the GUI or persistence side of things though (but then what's wrong with editing a config file with a text editor ?).
Upvotes: 6
Reputation: 2128
I've often used a simple wrapper around pugxml. I find that creating a configuration class with parameter validation for enumerated types and so on makes the rest of the code much cleaner. If you are just dealing with key/value pairs you will have to validate the data all throughout your code. By writing a custom class for each application you can put all that in one place.
Upvotes: 0
Reputation: 20267
The multi platform ACE library has a configuration class that uses config files that have the Windows .ini format.
Upvotes: 0
Reputation: 16486
I've used a modified version of John Torjo code from TechRepublic/DDJ (source)
Upvotes: 0