Configuration Template Library


Configuration Template Library is intended to help developers in managing configuration resources like command line, environment variables, configuration files.

The library provides easy and common interface to all types of configuration data storage sources and allows user to create own parsers for other sources like XML, RDBMS, LDAP.

The library is shipped as single header file and, thus, requires no special steps to be done. Some components of the library extensively use several BOOST and STL classes, command line parser uses GNU getopt, so if you don't have GNU LIBC installed you can find a lot of getopt flavors on

Quick howto

Typical usage of the config_manager:

#include <ctlib.h>
#include <iostream>


ctlib::config_manager<> a_cm;

std::istringstream a_stream("key1=val1\nkey2=val2\nbool_key=true\nint_key=1\nfloat_key=1.0f");
ctlib::plain_parser<std::stringstream> a_parser(&a_stream);
ctlib::config<> a_conf(&a_parser);

a_cm.add("Unique config id", a_conf);

std::cout << "Key1='" << a_cm.get("key1", "") << "'" << std::endl;
std::cout << "Key2='" << a_cm.get("key2", "") << "'" << std::endl;

// Conversion example
// Required type is deduced from the second parameter
int a_int = a_cm.get("int_key", int());
bool a_bool = a_cm.get("bool_key", bool());
float a_float = a_cm.get("float_key", float());

std::cout << "int " << a_int << std::endl;
std::cout << "bool " << a_bool << std::endl;
std::cout << "float " << a_float << std::endl;

Note that parsing is separate process - it's not invoked in add method.


You can download the library and Doxygen documentation using downloads link


Parsers usage examples:

Config usage examples:

Config manager usage examples:

Copyright © 2004, Stas Polevic, email:

Permission to use, copy, modify and redistribute this document for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies.