ConfigFile

From King Arthur's Gold Wiki
Jump to: navigation, search

The object used to read/write the contents of .cfg files


This object type has two constructors - one taking no arguments which creates an empty ConfigFile, the other taking a path to a .cfg file, which functions the same as the empty constructor followed by a call to ConfigFile::loadFile, with the caveat that if the file does not exist it will still set the ConfigFile's internal path to it, so that the specified file will be created upon calling ConfigFile::saveFile without a filepath parameter.

Methods:

Method Description
loadFile

Load the given .cfg file into the ConfigFile. Returns true if this was successful, otherwise false.

saveFile

Save the given .cfg file into the ConfigFile. Returns true if this was successful, otherwise false.

add_(type)

Adds a key/value pair with a value of a particular type to the ConfigFile. The type is specified by the specific method name used.

addArray_(type)

Adds the given key with a semicolon-delimited list of values of a particular type to the ConfigFile. The type is specified by the specific method name used.

read_(type)

Returns a value of a particular type for the given key, if it currently exists in the ConfigFile. The type is specified by the specific method name used.

readIntoArray_(type)

Reads a semicolon-delimited list of values of a particular type into the given array<T>. The type is specified by the specific method name used. Returns true if the given key existed and was successfully loaded into the array, otherwise false.

remove

Removes the given key (and its value) if it currently exists in the ConfigFile.

keyExists

Returns true if the given key currently exists (has been set) in the ConfigFile, otherwise false.