ConfigFile::readIntoArray (type)

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

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.


In order to use this method you must create an array<T> of the required type and then pass it to this method. If the specified key exists (and is of the right type) then the values in it will be loaded into the array.

You don't need to check in advance if the given key exists for this method, as it will return false if it does not.

bool readIntoArray_f32( array<f32> &inout arr, const string &in key )
bool readIntoArray_u8( array<u8> &inout arr, const string &in key )
bool readIntoArray_s8( array<s8> &inout arr, const string &in key )
bool readIntoArray_u16( array<u16> &inout arr, const string &in key )
bool readIntoArray_s16( array<s16> &inout arr, const string &in key )
bool readIntoArray_u32( array<u32> &inout arr, const string &in key )
bool readIntoArray_s32( array<s32> &inout arr, const string &in key )
bool readIntoArray_bool( array<bool> &inout arr, const string &in key )
bool readIntoArray_string( array<string> &inout arr, const string &in key )

Example of usage, assuming "testkey = test1; test2; test3" was already present in file Rules/TestRules/TEST.cfg:

ConfigFile config( "Rules/TestRules/TEST" );
 
array<string> test;
 
if (config.readIntoArray_string(test, "testkey") ){
  // The array test will now be loaded with the 3 values test1, test2 and test3, so we could do something with those values here if we wanted
}

Object method of: ConfigFile