incron  0.5.10
Static Public Member Functions | Static Protected Member Functions
IncronCfg Class Reference

Configuration class. More...

#include <incroncfg.h>

List of all members.

Static Public Member Functions

static void Init ()
 Initializes default configuration values.
static void Load (const std::string &rPath)
 Loads configuration values.
static bool GetValue (const std::string &rKey, std::string &rVal)
 Retrieves a configuration value.
static bool GetValue (const std::string &rKey, int &rVal)
 Retrieves a configuration value.
static bool GetValue (const std::string &rKey, unsigned &rVal)
 Retrieves a configuration value.
static bool GetValue (const std::string &rKey, bool &rVal)
 Retrieves a configuration value.
static std::string BuildPath (const std::string &rPath, const std::string &rName)
 Builds a file path.

Static Protected Member Functions

static bool ParseLine (const char *s, std::string &rKey, std::string &rVal)
 Parses a line a attempts to get a key and a value.
static bool IsComment (const char *s)
 Checks whether a line is a comment.

Detailed Description

Configuration class.

This class provides access to values loaded from a configuration file (either a explicitly specified one or the default one).


Member Function Documentation

std::string IncronCfg::BuildPath ( const std::string &  rPath,
const std::string &  rName 
) [static]

Builds a file path.

This function composes a path from a base path and a file name.

Parameters:
[in]rPathbase path
[in]rNamefile name
Returns:
full path
bool IncronCfg::GetValue ( const std::string &  rKey,
std::string &  rVal 
) [static]

Retrieves a configuration value.

This method attempts to find the appropriate configuration value for the given key and stores it into the given variable.

Parameters:
[in]rKeyvalue key
[out]rValretrieved value
Returns:
true = success, false = failure (invalid key)
bool IncronCfg::GetValue ( const std::string &  rKey,
int &  rVal 
) [static]

Retrieves a configuration value.

This method attempts to find the appropriate configuration value for the given key and stores it into the given variable.

Parameters:
[in]rKeyvalue key
[out]rValretrieved value
Returns:
true = success, false = failure (invalid key)
bool IncronCfg::GetValue ( const std::string &  rKey,
unsigned &  rVal 
) [static]

Retrieves a configuration value.

This method attempts to find the appropriate configuration value for the given key and stores it into the given variable.

Parameters:
[in]rKeyvalue key
[out]rValretrieved value
Returns:
true = success, false = failure (invalid key)
bool IncronCfg::GetValue ( const std::string &  rKey,
bool &  rVal 
) [static]

Retrieves a configuration value.

This method attempts to find the appropriate configuration value for the given key and stores it into the given variable.

Parameters:
[in]rKeyvalue key
[out]rValretrieved value
Returns:
true = success, false = failure (invalid key)
void IncronCfg::Init ( ) [static]

Initializes default configuration values.

bool IncronCfg::IsComment ( const char *  s) [static, protected]

Checks whether a line is a comment.

Parameters:
[in]stext line
Returns:
true = comment, false = otherwise
void IncronCfg::Load ( const std::string &  rPath) [static]

Loads configuration values.

This method attempts to load configuration values from the specified file. If it fails (e.g. the file doesn't exist) the default file is read. As the last resort (for the case the default file can't be loaded) the hard-wired values are used.

Parameters:
[in]rPathconfiguration file path
bool IncronCfg::ParseLine ( const char *  s,
std::string &  rKey,
std::string &  rVal 
) [static, protected]

Parses a line a attempts to get a key and a value.

Parameters:
[in]stext line
[out]rKeykey
[out]rValvalue
Returns:
true = success, false = failure

The documentation for this class was generated from the following files: