A class for reading configuration files that is on the famous INI file format. More...
#include <AsyncConfig.h>
A class for reading configuration files that is on the famous INI file format.
This class is used to read configuration files that is on the famous MS Windows INI file format. An example of a configuration file and how to use the class is shown below.
[SECTION1] VALUE1=The value VALUE2="Hello, " "multi line " "value!" [SECTION2] VALUE1="Whatever you want"
#include <iostream> #include <string> #include <cstdlib> #include <AsyncConfig.h> using namespace std; using namespace Async; int main(int argc, char **argv) { Config cfg; if (!cfg.open("test.cfg")) { cerr << "*** Error: Could not open config file test.cfg\n"; exit(1); } string value; if (cfg.getValue("SECTION1", "VALUE2", value)) { cout << ">>> value=" << value << endl; } else { cerr << "*** Error: Could not find config variable SECTION1/VALUE2\n"; exit(1); } }
Definition at line 134 of file AsyncConfig.h.
Async::Config::Config | ( | void | ) |
Default constuctor.
Async::Config::~Config | ( | void | ) |
Destructor.
bool Async::Config::getValue | ( | const std::string & | section, | |
const std::string & | tag, | |||
std::string & | value | |||
) |
Get the value of the given configuration variable.
section | The name of the section where the configuration variable is located | |
tag | The name of the configuration variable to get | |
value | The value is returned in this argument. Any previous contents is wiped |
std::list<std::string> Async::Config::listSection | ( | const std::string & | section | ) |
Return the name of all the tags in the given section.
section | The name of the section where the configuration variables are located |
bool Async::Config::open | ( | const std::string & | name | ) |
Open the given config file.
name | The name of the configuration file to open |