Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

Config Class Reference
[Config]

A class which encapsulates config settings. More...

#include <Config.h>

List of all members.

Public Methods

 Config ()
 Default Constructor.

 Config (const string file)
 Constructor.

 ~Config ()
 Destructor.

bool has_key (const string key)
 A function to find if a setting name exists.

bool set (const string key, string value)
 Insert or modify an existing setting.

bool get (const string key, string &value)
 Retrieve an existing setting, should it exist.

bool store_settings ()
 Store all settings to the backing file.

bool load_settings ()
 Load settins from a stored file.


Detailed Description

A class which encapsulates config settings.

This class should be used to fetch/store any configuration settings used by the client (or the server). There are no groups for the settings, so the preferred convention for naming settings is: (client/server).(module).(setting). Thus, for a client's audio setting, client.audio.setting would be appropriate. This allows for clear distinction among settings and where they come from.

Each configuration class must be backed by a file, which it will load from and write to both explicitly, and upon construction and destruction.

Definition at line 38 of file Config.h.


Constructor & Destructor Documentation

Config::Config  
 

Default Constructor.

Initializes the internal data for storing the settings and uses the default configuaration file.

Definition at line 7 of file Config.cpp.

References load_settings().

Config::Config const string    file
 

Constructor.

Initializes the internal data for storing these settings and uses the specified file name to store these settings.

Parameters:
file  a file name used to store the settings.

Definition at line 12 of file Config.cpp.

References load_settings().

Config::~Config  
 

Destructor.

Deletes all internal data after storing settings to the backing file.

Definition at line 17 of file Config.cpp.

References store_settings().


Member Function Documentation

bool Config::get const string    key,
string &    value
 

Retrieve an existing setting, should it exist.

Parameters:
key  the setting name to look for
value  reference to a string which the value will be set to, should it be found.
Returns:
false if the key is invalid or the setting doesn't exist.

Definition at line 96 of file Config.cpp.

bool Config::has_key const string    key
 

A function to find if a setting name exists.

Parameters:
key  the setting name to look for
Returns:
whether or not this settings object has that setting

Definition at line 80 of file Config.cpp.

bool Config::load_settings  
 

Load settins from a stored file.

Returns:
false if the file exists and could not be opened for reading.

Definition at line 22 of file Config.cpp.

Referenced by Config().

bool Config::set const string    key,
string    value
 

Insert or modify an existing setting.

This function will insert a setting and its associated value into the list of settings. Keys cannot contain spaces.

NOTE: This will overwrite any existing setting by that name.

Parameters:
key  the setting name to insert.
value  the value to associated with the setting name.
Returns:
false if they key is invalid.

Definition at line 84 of file Config.cpp.

bool Config::store_settings  
 

Store all settings to the backing file.

Returns:
false if the file could not be opened for writing.

Definition at line 51 of file Config.cpp.

Referenced by ~Config().


The documentation for this class was generated from the following files:
Generated on Thu Aug 18 16:03:36 2005 for Robin Hood: Thieves & Knights by doxygen1.2.18