Difference between revisions of "ConfigFile::addArray (type)"

From King Arthur's Gold Wiki
Jump to: navigation, search
(Created page with "<onlyinclude> 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. </onlyi...")
 
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
 
</onlyinclude>
 
</onlyinclude>
  
In order to use this method you must create an array<T> of the required type, add the necessary values to it and then pass it to this method.
+
In order to use this method you must create an [[array]]<T> of the required type, add the necessary values to it and then pass it to this method.
The array will then be converted into a semicolon-delimited list with the same values as were in the array<T>.
+
The [[array]] will then be converted into a semicolon-delimited list with the same values as were in the [[array]]<T>.
 
   
 
   
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">
Line 18: Line 18:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Example of usage:
+
Example of usage, adding "testkey = test1; test2; test3" to the file Rules/TestRules/TEST.cfg:
 
<syntaxhighlight lang="cpp" highlight="8">
 
<syntaxhighlight lang="cpp" highlight="8">
 
ConfigFile config( "Rules/TestRules/TEST" );
 
ConfigFile config( "Rules/TestRules/TEST" );

Latest revision as of 16:55, 29 September 2012

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.


In order to use this method you must create an array<T> of the required type, add the necessary values to it and then pass it to this method. The array will then be converted into a semicolon-delimited list with the same values as were in the array<T>.

void addArray_f32( const string &in key, const array<f32> &in value )
void addArray_u8( const string &in key, const array<u8> &in value )
void addArray_s8( const string &in key, const array<s8> &in value )
void addArray_u16( const string &in key, const array<u16> &in value )
void addArray_s16( const string &in key, const array<s16> &in value )
void addArray_u32( const string &in key, const array<u32> &in value )
void addArray_s32( const string &in key, const array<s32> &in value )
void addArray_bool( const string &in key, const array<bool> &in value )
void addArray_string( const string &in key, const array<string> &in value )

Example of usage, adding "testkey = test1; test2; test3" to the file Rules/TestRules/TEST.cfg:

ConfigFile config( "Rules/TestRules/TEST" );
 
array<string> test;
test.push_back("test1");
test.push_back("test2");
test.push_back("test3");
 
config.addArray_string("testkey", test);config.saveFile();

Object method of: ConfigFile