|
|
KIniReader :
#include "KIniReader.h"
KIniReader is responsible for reading external ini files.
INI files are text files that contain some information about the game, they must be in the following format:
[SECTIONNAME]
variable=value
name=string
INI files are plain texts files, the file extension does not matter.
Be careful not to insert leading spaces at this point, V1.0 does not strip the spaces and that might result in errors. |
Quick Reference
setIni
getValue
getString
|
|
bool setIni( char *iniFile)
|
Loads the the ini file in memory.
Example :
KIniReader *iniReader ;
iniReader = new KIniReader ;
iniReader->setIni( KMiscTools::makeFilePath( "envariables.ini" ) ; |
long getValue( char *section , char *variable , long defaultValue)
|
Reads a value from an ini file.
defaultValue is optional, it will be returned in case the entry doesn't exist or the reading failed.
Example :
long value ;
value = myIni->getValue( "MONSTERS" , "QUANTITY" ) ;
|
| bool getString( char *section , char *variable, char *buffer,long bufferlen ) |
Reads a string from an ini file
Section represents the section name ( the group [ ] )
Variable represents the variable to read from the section.
buffer points to a buffer that will receive the string
bufferlen must contain the length of the buffer
Example :
char buffer[256]; //allocate a buffer of 256 chars
myIni->getString( "ENGLISH" , "NAME" , buffer , 256 ) ; |
|