Async::Config Class Reference

A class for reading configuration files that is on the famous INI file format. More...

#include <AsyncConfig.h>

List of all members.

Public Member Functions


Detailed Description

A class for reading configuration files that is on the famous INI file format.

Author:
Tobias Blomberg
Date:
2004-03-17

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);
  }
}
Examples:

AsyncConfig_demo.cpp.

Definition at line 134 of file AsyncConfig.h.


Constructor & Destructor Documentation

Async::Config::Config ( void   ) 

Default constuctor.

Async::Config::~Config ( void   ) 

Destructor.


Member Function Documentation

bool Async::Config::getValue ( const std::string &  section,
const std::string &  tag,
std::string &  value 
)

Get the value of the given configuration variable.

Parameters:
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
Returns:
Returns true on success or else false on failure
Examples:
AsyncConfig_demo.cpp.
std::list<std::string> Async::Config::listSection ( const std::string &  section  ) 

Return the name of all the tags in the given section.

Parameters:
section The name of the section where the configuration variables are located
Returns:
Returns the list of tags in the given section
bool Async::Config::open ( const std::string &  name  ) 

Open the given config file.

Parameters:
name The name of the configuration file to open
Returns:
Returns true on success or else false.
Examples:
AsyncConfig_demo.cpp.

The documentation for this class was generated from the following file:
Generated by  doxygen 1.6.2-20100208