Vita::config – reading config files
In a follow-up to my post about Vita::string, I release another part of my micro-library: class serving as a gateway to simple configuration files.
Vita::config is able to load a configuration file and put the key-value pairs into
std::map<Vita::string, Vita::string>. All values are thus easily accessible and convertible,
and one can use everything Vita::string offers. A sample usage:
Vita::config config1("test.conf"); double pi = config1.get("pi").convert<double>(); std::cout << config1.get("shell").ucfirst();
Configuration files are expected to be in the usual UNIX form; white space and comments are ignored, of course.
# Comment key1 = value1 key2 = value2
Configuration can be easily written, too:
Vita::config config2; config2.set("euler", "2.718281828"); config2.saveFile("new-config.conf");
See the demo/ directory in the archives for more examples. As usual, library documentation is contained
in the downloadable archives and available for on-line browsing.
- vita-2.0.tar.bz2 (51kB)
- vita-2.0.tar.gz (56kB)
- vita-2.0.zip (77kB)
Speak your mind
Allowed HTML tags are a, blockquote, em, code, li, ol, p, pre, strong, ul. Links to other comments in the form “[IV]” or “[4]” are detected automatically.