Ares
Public Member Functions | Private Member Functions | Private Attributes

INI_EX Class Reference

#include <src/Utilities/INIParser.h>

List of all members.

Public Member Functions

 INI_EX (CCINIClass *iniFile)
bool ReadString (const char *pSection, const char *pKey)
const char * value ()
bool declared () const
bool ReadBool (const char *pSection, const char *pKey, bool *bBuffer)
bool ParseBool (const bool bDefault)
bool ReadInteger (const char *pSection, const char *pKey, int *nBuffer)
int ParseInteger (const int nDefault)
bool Read2Integers (const char *pSection, const char *pKey, int *nBuffer)
int * Parse2Integers (int *buffer)
bool Read3Integers (const char *pSection, const char *pKey, int *nBuffer)
int * Parse3Integers (int *buffer)
bool Read4Integers (const char *pSection, const char *pKey, int *nBuffer)
int * Parse4Integers (int *buffer)
bool Read3Bytes (const char *pSection, const char *pKey, byte *nBuffer)
byte * Parse3Bytes (byte *buffer)
bool ReadDouble (const char *pSection, const char *pKey, double *nBuffer)
double ParseDouble (double nDefault)

Private Member Functions

char * buffer ()
int buflen ()

Private Attributes

CCINIClass * pINI

Constructor & Destructor Documentation

INI_EX::INI_EX ( CCINIClass *  iniFile) [inline]
         : pINI(iniFile)
        {};

Member Function Documentation

char* INI_EX::buffer ( ) [inline, private]
                        {
                return Ares::readBuffer;
        }
int INI_EX::buflen ( ) [inline, private]
                     {
                return Ares::readLength;
        }
bool INI_EX::declared ( ) const [inline]
                              {
                return !!Ares::readBuffer[0];
        }
int* INI_EX::Parse2Integers ( int *  buffer) [inline]
                                         {
                sscanf(this->buffer(), "%d,%d", &buffer[0], &buffer[1]);
                return buffer;
        }
byte* INI_EX::Parse3Bytes ( byte *  buffer) [inline]
                                        {
                int iBuffer [3];
                iBuffer[0] = buffer[0];
                iBuffer[1] = buffer[1];
                iBuffer[2] = buffer[2];

                sscanf(this->buffer(), "%d,%d,%d", &iBuffer[0], &iBuffer[1], &iBuffer[2]);

                buffer[0] = (byte)iBuffer[0];
                buffer[1] = (byte)iBuffer[1];
                buffer[2] = (byte)iBuffer[2];
                return buffer;
        }
int* INI_EX::Parse3Integers ( int *  buffer) [inline]
                                         {
                sscanf(this->buffer(), "%d,%d,%d", &buffer[0], &buffer[1], &buffer[2]);
                return buffer;
        }
int* INI_EX::Parse4Integers ( int *  buffer) [inline]
                                         {
                sscanf(this->buffer(), "%d,%d,%d,%d", &buffer[0], &buffer[1], &buffer[2], &buffer[3]);
                return buffer;
        }
bool INI_EX::ParseBool ( const bool  bDefault) [inline]
                                            {
                switch(toupper(*this->buffer())) {
                        case '1':
                        case 'T':
                        case 'Y':
                                return true;
                        case '0':
                        case 'F':
                        case 'N':
                                return false;
                        default:
                                return bDefault;
                }
        }
double INI_EX::ParseDouble ( double  nDefault) [inline]
                                            {
                double buffer = nDefault;
                sscanf(this->buffer(), "%lf", &buffer);
                if(strchr(this->buffer(), '%')) {
                        buffer *= 0.01;
                }
                return buffer;
        }
int INI_EX::ParseInteger ( const int  nDefault) [inline]
                                             {
                int buffer = nDefault;

                const char *pValue = this->buffer();

                if(*pValue == '$') {
                        sscanf(pValue, "$%d", &buffer);
                        return buffer;
                }

                if(tolower(pValue[strlen(pValue) - 2]) == 'h') {
                        sscanf(pValue, "%xh", &buffer);
                        return buffer;
                }

                sscanf(pValue, "%d", &buffer);
                return buffer;
        }
bool INI_EX::Read2Integers ( const char *  pSection,
const char *  pKey,
int *  nBuffer 
) [inline]
                                                                                 {
                if(!this->ReadString(pSection, pKey)) {
                        return false;
                }
                this->Parse2Integers(nBuffer);
                return true;
        }
bool INI_EX::Read3Bytes ( const char *  pSection,
const char *  pKey,
byte *  nBuffer 
) [inline]
                                                                               {
                if(!this->ReadString(pSection, pKey)) {
                        return false;
                }
                this->Parse3Bytes(nBuffer);
                return true;
        }
bool INI_EX::Read3Integers ( const char *  pSection,
const char *  pKey,
int *  nBuffer 
) [inline]
                                                                                 {
                if(!this->ReadString(pSection, pKey)) {
                        return false;
                }
                this->Parse3Integers(nBuffer);
                return true;
        }
bool INI_EX::Read4Integers ( const char *  pSection,
const char *  pKey,
int *  nBuffer 
) [inline]
                                                                                 {
                if(!this->ReadString(pSection, pKey)) {
                        return false;
                }
                this->Parse4Integers(nBuffer);
                return true;
        }
bool INI_EX::ReadBool ( const char *  pSection,
const char *  pKey,
bool *  bBuffer 
) [inline]
                                                                             {
                if(!this->ReadString(pSection, pKey)) {
                        return false;
                }
                *bBuffer = this->ParseBool(*bBuffer);
                return true;
        }
bool INI_EX::ReadDouble ( const char *  pSection,
const char *  pKey,
double *  nBuffer 
) [inline]
                                                                                 {
                if(!this->ReadString(pSection, pKey)) {
                        return false;
                }
                *nBuffer = this->ParseDouble(*nBuffer);
                return true;
        }
bool INI_EX::ReadInteger ( const char *  pSection,
const char *  pKey,
int *  nBuffer 
) [inline]
                                                                               {
                if(!this->ReadString(pSection, pKey)) {
                        return false;
                }
                *nBuffer = this->ParseInteger(*nBuffer);
                return true;
        }
bool INI_EX::ReadString ( const char *  pSection,
const char *  pKey 
) [inline]
                                                                {
                return pINI->ReadString(pSection, pKey, "", this->buffer(), this->buflen()) >= 1;
        }
const char* INI_EX::value ( ) [inline]
                             {
                return Ares::readBuffer;
        }

Member Data Documentation

CCINIClass* INI_EX::pINI [private]

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines