Note: If you are using Glib in any way you'd be better off to use Glib::KeyFile which is far more advanced. I know I probably will be in many projects. I'm sure there are other equivalent libraries as well.
libvcconfig is a very basic configuration file library. It's essentially a wrapper for a std::map<std::string,std::string> object with some parsing and file handling. Still in early stages, but works just fine.
libvcconfig tracks three types of items: strings, integers and booleans. They are all stored as strings at heart, but those are the ones implemented for convinience. Files are stored in index=value pairs, one per line. Comments start with a # and last to the end of the line.
Example Config File
# Example config file for your application someString=This can be any length string you want, just no newlines! # Blank lines don't hurt anything # Booleans are stored in all caps with an asterisk thisIsFalse=*FALSE thisIsTrue=*TRUE # The index can be anything you want THISisVALID=Really, it is. # Integers are stored as strings too, shady right? thisIsAnInt=12302
The configuration is all handled through the vcConfig object. Documentation
is available for each version below.
Be aware that you'll want to cast things alot, especially when setting strings.
Brief Example
// Brief example of libvcconfig basics. #include#include using std::cout; using std::endl; int main(int argc, char *argv[]) { vcConfig config; config.set("hello",string("world")); cout << "hello = " << config.getString("hello") << endl; config.set("helloBack",string("hi")); cout << "helloBack = " << config.getString("helloBack") << endl; config.set("integer",int(5)); cout << "integer = " << config.getInt("integer") << endl; config.set("integer",int(2)); cout << "integer = " << config.getInt("integer") << endl; config.set("boolean",bool(true)); if(config.getBool("boolean")) cout << "boolean is true" << endl; else cout << "boolean is false" << endl; cout << "Dump whole thing to screen..." << endl << config.toString() << endl; }
Subversion
ViewVC
Repository
Version 1.0.1
Documentation
Source
Linux c86 .so with installer
Version 1.0.0
Source
Linux x86 .so with installer