#include <Config.hpp>
Public Member Functions | |
Config (const std::string &fname="") | |
bool | load (const std::string &fname) |
void | save (const std::string &fname) const |
std::string & | operator[] (const std::string &key) |
std::vector< std::string > | keys () |
Friends | |
std::ostream & | operator<< (std::ostream &out, const Config &config) |
The Config class implements a micro config settings utility, a loadable, saveable, one-line-per-entry config class. It just wraps a lookup table with a configuration file input/output, and a stream output.
A configuration file myapp.conf
may look like:
bites::Config::Config | ( | const std::string & | fname = "" | ) |
Create config object, optionally load from file.
fname | name of existing file. |
bool bites::Config::load | ( | const std::string & | fname | ) |
Load config contents from file.
fname | name of input file. |
void bites::Config::save | ( | const std::string & | fname | ) | const |
Save config contents to file.
fname | name of output file. |
std::string & bites::Config::operator[] | ( | const std::string & | key | ) |
Access configuration setting.
key | configuration setting to access for read/write. |
std::vector< std::string > bites::Config::keys | ( | ) |
Return all keys (names of settings) present in the configuration.
|
friend |
Dump configuration to stream.
out | output destination stream. |
config | the configuration whose contents are dumped. |