Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members   File Members  

ZE::ZConfigFile Class Reference

#include <ZE_ZConfigFile.h>

List of all members.


Detailed Description

ZConfigFile class for INI-style configuration files for games or applications. Inherited from ZObject.


Public Methods

 ZConfigFile ()
 Default constructor.

 ZConfigFile (string filename)
 Constructor which takes filename.

virtual ~ZConfigFile ()
 Destructor, flushes file.

void Process (string filename)
 Parse a file.

float GetFloat (string section, string var, float defVal) const
 Get value in floating point format from file.

int GetInt (string section, string var, int defVal) const
 Get value in integer format from file.

bool GetBool (string section, string var, bool defVal) const
 Get value in boolean format from file.

string GetString (string section, string var, string defVal) const
 Get value in string format from file.

void SetFloat (string section, string var, float val)
 Set value in floating point format in file.

void SetInt (string section, string var, int val)
 Set value in integer format in file.

void SetBool (string section, string var, bool val)
 Set value in boolean format in file.

void SetString (string section, string var, string val)
 Set value in string format in file.

void Flush ()
 Write all values to file.

void Close ()
 Close the file.


Protected Methods

string CleanString (string str) const
 Reformat a string in a form more suitable to parsing.

bool Exists (string sec) const
 Check if a section exists.

bool Exists (string sec, string var) const
 Check if a variable exists.

void SetVariable (string sec, string var, string val)
 Internal function to set variables.

string GetVariable (string sec, string var, string defVal) const
 Internal function to get value of a variable.


Protected Attributes

list< ZCF_SectionrFileLayout
 List of sections of internal type.

string rFilename
 Filename of file currently open.


Constructor & Destructor Documentation

ZE::ZConfigFile::ZConfigFile  
 

A no-op default constructor.

ZE::ZConfigFile::ZConfigFile string    filename
 

Constructor takes filename, and calls process on it.

Parameters:
filename File to load as ZConfigFile.

ZE::ZConfigFile::~ZConfigFile   [virtual]
 

Flushes the file, ensures a flush if the file is left open.


Member Function Documentation

string ZE::ZConfigFile::CleanString string    str const [protected]
 

Removes whitespace from a string and makes all characters lowercase.

Parameters:
str The string to get a clean version of.
Returns:
Cleaned string.

bool ZE::ZConfigFile::Exists string    sec const [protected]
 

Find out if a section currently exists.

Parameters:
sec Section to check for.
Returns:
bool, true if section exists in file.

bool ZE::ZConfigFile::Exists string    sec,
string    var
const [protected]
 

Find out if a variable currently exists.

Parameters:
sec Section to check in.
var Variable to check for.
Returns:
bool, true if section exists in file.

void ZE::ZConfigFile::SetVariable string    sec,
string    var,
string    val
[protected]
 

Set variable to value, called internally only.

Parameters:
sec Section for variable.
var Variable to set.
val Value to set variable to.

string ZE::ZConfigFile::GetVariable string    sec,
string    var,
string    defVal
const [protected]
 

Get value of variable, called internally only.

Parameters:
sec Section for variable.
var Variable to get.
defVal Value to return if variable doesnt exist.
Returns:
Value of variable.

void ZE::ZConfigFile::Process string    filename
 

Parses the file, reading the contents into the fileLayout map.

Parameters:
filename File to parse and attach this ZDataFile to.

float ZE::ZConfigFile::GetFloat string    section,
string    var,
float    defVal
const
 

Get the current value of a variable in the file, or defVal if not found in file.

Since:
0.8.3
Parameters:
section Name of section to seek variable under.
var Name of variable to seek value for.
defVal Value to return if var does not exist within section.
Returns:
Contents of the variable in floating point format.

int ZE::ZConfigFile::GetInt string    section,
string    var,
int    defVal
const
 

Get the current value of a variable in the file, or defVal if not found in file.

Parameters:
section Name of section to seek variable under.
var Name of variable to seek value for.
defVal Value to return if var does not exist within section.
Returns:
Contents of the variable in integer format.

bool ZE::ZConfigFile::GetBool string    section,
string    var,
bool    defVal
const
 

Get the current value of a variable in the file, or defVal if not found in file. (Valid values are "0","1","true" and "false")

Parameters:
section Name of section to seek variable under.
var Name of variable to seek value for.
defVal Value to return if var does not exist within section.
Returns:
Contents of the variable in boolean format.

string ZE::ZConfigFile::GetString string    section,
string    var,
string    defVal
const
 

Get the current value of a variable in the file, or defVal if not found in file.

Parameters:
section Name of section to seek variable under.
var Name of variable to seek value for.
defVal Value to return if var does not exist within section.
Returns:
Contents of the variable in string format.

void ZE::ZConfigFile::SetFloat string    section,
string    var,
float    val
 

Set the new value of a variable in the file to val, creating the section and variable if not already found in file.

Since:
0.8.3
Parameters:
section Name of section to edit variable under.
var Name of variable to set value for.
val Floating point value to set variable to in file.

void ZE::ZConfigFile::SetInt string    section,
string    var,
int    val
 

Set the new value of a variable in the file to val, creating the section and variable if not already found in file.

Parameters:
section Name of section to edit variable under.
var Name of variable to set value for.
val Integer value to set variable to in file.

void ZE::ZConfigFile::SetBool string    section,
string    var,
bool    val
 

Set the new value of a variable in the file to val, creating the section and variable if not already found in file.

Parameters:
section Name of section to edit variable under.
var Name of variable to set value for.
val Boolean value to set variable to in file.

void ZE::ZConfigFile::SetString string    section,
string    var,
string    val
 

Set the new value of a variable in the file to val, creating the section and variable if not already found in file.

Parameters:
section Name of section to edit variable under.
var Name of variable to set value for.
val String value to set variable to in file.

void ZE::ZConfigFile::Flush  
 

Writes all values and sections to file.

void ZE::ZConfigFile::Close  
 

Flush the file and clear the filename.


The documentation for this class was generated from the following files:
Generated on Sun Apr 27 22:34:35 2003 for ZEngine by doxygen1.3-rc2