Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ZE::ZConfigFile Class Reference

#include <ZE_ZConfigFile.h>

Inherits ZE::ZObject.

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.

 ~ZConfigFile ()
 Destructor, flushes file.

void Process (string filename)
 Parse a file.

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

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

string GetString (string section, string var, string defVal)
 Get value in string format from 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.


Private Methods

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

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

bool Exists (string sec, string var)
 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)
 Internal function to get value of a variable.


Private Attributes

list< ZCF_SectionmFileLayout
 List of sections of internal type.

string mFilename
 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  
 

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


Member Function Documentation

string ZE::ZConfigFile::CleanString string    str [private]
 

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 [private]
 

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
[private]
 

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
[private]
 

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
[private]
 

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.

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

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
 

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
 

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::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 Wed Dec 4 19:16:09 2002 for ZEngine by doxygen1.3-rc1