Config Class Reference

Provides a service to read and write game config data. More...

#include <config.h>

List of all members.

Public Member Functions

 Config (irr::IrrlichtDevice *d)
 ~Config ()
 Destructor.
void loadConfig (irr::c8 *fileName)
void safeConfig (irr::c8 *description, irr::c8 *fileName)
void safeDefaultConfig (const irr::c8 *fileName)
virtual void setParameter (const irr::c8 *parameterName, const irr::c8 *value)
virtual const irr::c8 * getParameter (const irr::c8 *parameterName)
virtual void setParameter (const irr::c8 *parameterName, bool value)
 Sets a parameter as boolean value.
virtual bool getParameterAsBool (const irr::c8 *parameterName)
virtual void setParameter (const irr::c8 *parameterName, irr::s32 value)
 Sets a parameter as integer value.
virtual irr::s32 getParameterAsInt (const irr::c8 *parameterName)
virtual void setParameter (const irr::c8 *parameterName, irr::f32 value)
 Sets a parameter as float value.
virtual irr::f32 getParameterAsFloat (const irr::c8 *parameterName)
virtual irr::s32 getParameterCount ()
 Returns amount of string parameters set in this scene manager.
virtual const irr::c8 * getParameterName (irr::s32 index)
virtual const irr::c8 * getParameterValue (irr::s32 index)

Classes

struct  SStringPair


Detailed Description

Provides a service to read and write game config data.

Game config data is stored to disk in simple XML format. To do so, just create a Config object, set some Parametes using the set() functions and safe to disk. Setting Parameters is done with a uniuqe parameter Name followed by a value. Reading game config Parameters is done by creating a Config object, then load() a file. Calling get() functions returns then Paramter values by a given name (null terminated string). This class is based on irr::IStringParameters.

Definition at line 16 of file config.h.


Constructor & Destructor Documentation

Config::Config irr::IrrlichtDevice *  d  ) 
 

Constructor

Parameters:
d : An IrrlichtDevice*, needed to access filesystem.


Member Function Documentation

virtual const irr::c8* Config::getParameter const irr::c8 *  parameterName  )  [virtual]
 

Gets a string parameter.

Parameters:
parameterName : Name of the parameter to get.
Returns:
Returns value of the parameter previously set by setStringParameter() or 0 if parameter is not set.

virtual bool Config::getParameterAsBool const irr::c8 *  parameterName  )  [virtual]
 

Gets a parameter as boolean value.

Parameters:
parameterName : Name of the parameter to get.
Returns:
Returns value of the parameter previously set by setParameter() as bool or 0 if parameter is not set.

virtual irr::f32 Config::getParameterAsFloat const irr::c8 *  parameterName  )  [virtual]
 

Gets a parameter as integer value.

Parameters:
parameterName : Name of the parameter to get.
Returns:
Returns value of the parameter previously set by setParameter() as float value or 0 if parameter is not set.

virtual irr::s32 Config::getParameterAsInt const irr::c8 *  parameterName  )  [virtual]
 

Gets a parameter as integer value.

Parameters:
parameterName : Name of the parameter to get.
Returns:
Returns value of the parameter previously set by setParameter() as integer or 0 if parameter is not set.

virtual const irr::c8* Config::getParameterName irr::s32  index  )  [virtual]
 

Returns string parameter name by index.

Parameters:
index : Index value, must be between 0 and getStringParameterCount()-1

Referenced by ~Config().

virtual const irr::c8* Config::getParameterValue irr::s32  index  )  [virtual]
 

Returns string parameter value by index

Parameters:
index : Index value, must be between 0 and getStringParameterCount()-1

void Config::loadConfig irr::c8 *  fileName  ) 
 

Loads a XML file from disk.

Parameters:
fileName : A string (path and filename).

void Config::safeConfig irr::c8 *  description,
irr::c8 *  fileName
 

Safes a XML file to disk.

Parameters:
description : A string describing content of file. Should be short (one single word)!
fileName : A string (path and filename).

void Config::safeDefaultConfig const irr::c8 *  fileName  ) 
 

Safes a XML file to disk which contains some example Parameters. You can edit the resulting file with Notepad and load again. Just to let you have a template...

Parameters:
fileName : A string (path and filename).

virtual void Config::setParameter const irr::c8 *  parameterName,
const irr::c8 *  value
[virtual]
 

Sets a string parameter.

Parameters:
parameterName : Name for the parameter.
value : Value for the parameter. Set this to 0 to delete the parameter.

Referenced by ~Config().


The documentation for this class was generated from the following files:
Generated on Sun Dec 2 17:09:58 2007 for Swarm by  doxygen 1.4.6-NO