Difference between revisions of "ConfigFile"
Shadlington (Talk | contribs) |
Shadlington (Talk | contribs) |
||
Line 1: | Line 1: | ||
<onlyinclude> | <onlyinclude> | ||
− | The object used to read the contents of .cfg files | + | The object used to read/write the contents of .cfg files |
</onlyinclude> | </onlyinclude> | ||
+ | |||
+ | 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]. | ||
+ | |||
+ | Methods: | ||
+ | {| class="wikitableShiny" | ||
+ | |- | ||
+ | ! '''Method''' | ||
+ | ! '''Description''' | ||
+ | |- | ||
+ | | [[ConfigFile::loadFile|loadFile]] | ||
+ | | {{:ConfigFile::loadFile|loadFile}} | ||
+ | |- | ||
+ | | [[ConfigFile::saveFile|saveFile]] | ||
+ | | {{:ConfigFile::saveFile|saveFile}} | ||
+ | |- | ||
+ | | [[ConfigFile::add_(type)|add_(type)]] | ||
+ | | {{:ConfigFile::add_(type)|add_(type)}} | ||
+ | |- | ||
+ | | [[ConfigFile::addArray_(type)|addArray_(type)]] | ||
+ | | {{:ConfigFile::addArray_(type)|addArray_(type)}} | ||
+ | |- | ||
+ | | [[ConfigFile::read_(type)|read_(type)]] | ||
+ | | {{:ConfigFile::read_(type)|read_(type)}} | ||
+ | |- | ||
+ | | [[ConfigFile::readIntoArray_(type)|readIntoArray_(type)]] | ||
+ | | {{:ConfigFile::readIntoArray_(type)|readIntoArray_(type)}} | ||
+ | |- | ||
+ | | [[ConfigFile::remove|remove]] | ||
+ | | {{:ConfigFile::remove|remove}} | ||
+ | |- | ||
+ | | [[ConfigFile::keyExists|keyExists]] | ||
+ | | {{:ConfigFile::keyExists|keyExists}} | ||
+ | |- | ||
+ | |} | ||
[[Category:Scripting]] | [[Category:Scripting]] | ||
[[Category:Object Types]] | [[Category:Object Types]] |
Revision as of 15:40, 29 September 2012
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].
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. |