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.


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.

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 Sun Dec 1 02:44:14 2002 for ZEngine by doxygen1.2.18