ConfigFile Class Reference

Loads a configuration file. More...

#include <Application/ConfigFile.h>

List of all members.

Classes

class  ConfigValue
 Holds a single config value. More...

Public Types

enum  ValueType {
  TYPE_UNKNOWN = -1, TYPE_FLOAT = 0, TYPE_INTEGER, TYPE_STRING,
  TYPE_BOOL, TYPE_VECTOR2, TYPE_COLOR4, TYPE_COUNT
}
 

Defins the diffeant types a value can have.

More...

Public Member Functions

 ConfigFile ()
 Constructs an empty config file.
 ConfigFile (const char *file)
 Constructs and loads a config file.
 ~ConfigFile ()
 Deconstructor.
bool Load (const char *file)
 Loads a config file.
bool Save (const char *name)
 Writes a config file.
const ConfigValueFindValueByName (const char *name) const
 Searches for the existance of a value by name.
const ConfigValueoperator[] (const char *name) const
 Retrieves a value.
bool SetValue (const char *name, const char *value)
 Creates or sets a value.
bool SetValue (const std::string &name, const std::string &value)
 Creates or sets a value.

Detailed Description

Loads a configuration file.

Each line of the config defines a key value pair in the following format:

key = value

Where key is a case-sensitve single string of charachters without spaces or newlines. Value is the data value associated with the key. To define a color use the color operator Color(r, g, b, a) where r, g, b, and a are in the range [0,1]. To define a vector use the Vector operator Vector(x, y). All other data types will be auto detected. If the type cannot be deduced, it is assumed to be a string.

Line comments are started with the ';' symbole. All characters in a line following a semi-colon are ignored.

Duplicate occurances of a single key will overwrite the previous value. The file is read from the top down.


Member Enumeration Documentation

Defins the diffeant types a value can have.

Enumerator:
TYPE_UNKNOWN 

Unknown type.

TYPE_FLOAT 

32-bit floating point number.

TYPE_INTEGER 

32-bit signed integer.

TYPE_STRING 

A null terminated string.

TYPE_BOOL 

A boolean value.

TYPE_VECTOR2 

A 2D floating point vector.

TYPE_COLOR4 

A 4 component floating point color.

TYPE_COUNT 

The number of types.


Constructor & Destructor Documentation

ConfigFile::ConfigFile ( const char *  file  ) 

Constructs and loads a config file.

Parameters:
[in] file the name of the config file to load.

Member Function Documentation

const ConfigFile::ConfigValue * ConfigFile::FindValueByName ( const char *  name  )  const

Searches for the existance of a value by name.

Parameters:
[in] name the name of the value to search for.
Returns:
The config value or NULL if the value does not exist.
bool ConfigFile::Load ( const char *  file  ) 

Loads a config file.

Parameters:
[in] file the name of the config file to load.
Returns:
true if the config file was loaded, false otherwise.
const ConfigFile::ConfigValue & ConfigFile::operator[] ( const char *  name  )  const

Retrieves a value.

Parameters:
[in] name the name of the value.
Returns:
the requested value.
bool ConfigFile::Save ( const char *  name  ) 

Writes a config file.

Parameters:
[in] name the name of the config file to write to.
Returns:
true if the config file was saved, false otherwise.
bool ConfigFile::SetValue ( const std::string &  name,
const std::string &  value 
)

Creates or sets a value.

Parameters:
[in] name the name of the value.
[in] value the value to associate with the value.
Returns:
true if the value was set, false otherwise.
bool ConfigFile::SetValue ( const char *  name,
const char *  value 
)

Creates or sets a value.

Parameters:
[in] name the name of the value.
[in] value the value to associate with the value.
Returns:
true if the value was set, false otherwise.

The documentation for this class was generated from the following files:
Generated on Mon Apr 5 19:08:05 2010 for BrickOut |ReDuX| by  doxygen 1.6.3