ADTF  3.18.3
cIniFile

INI file handling. More...

Public Member Functions

 cIniFile ()
 Default constructor.
 
virtual ~cIniFile ()
 Destructor.
 
tResult Load (const cFilename &strFilename="", const tBool &bParse=tTrue)
 Loads an INI file. More...
 
tResult Save (const cFilename &strFilename="")
 Saves an INI file. More...
 
tResult RemoveSection (const cString &strSection)
 Removes an entire section. More...
 
tResult RemoveKey (const cString &strSection, const cString &strName)
 Removes a key from a section. More...
 
tBool Set (const cString &strSection, const cString &strName, const cString &strValue="")
 Sets a string value. More...
 
tBool SetBool (const cString &strSection, const cString &strName, const tBool &bValue)
 Sets a bool value. More...
 
tBool SetInt (const cString &strSection, const cString &strName, const int &iValue)
 Sets an integer value. More...
 
tBool SetFloat64 (const cString &strSection, const cString &strName, const tFloat64 &f64Value)
 Sets a float value. More...
 
cString Get (const cString &strSection, const cString &strName, const cString &strDefault="") const
 Returns a string value. More...
 
tBool GetBool (const cString &strSection, const cString &strName, const tBool &bDefault=false) const
 Returns a bool value. More...
 
tBool Exists (const cString &strSection, const cString &strName) const
 Checks if an entry exists in the ini file. More...
 
int GetInt (const cString &strSection, const cString &strName, const int &iDefault=0) const
 Returns an integer value. More...
 
tFloat64 GetFloat64 (const cString &strSection, const cString &strName, const tFloat64 &f64Default=0) const
 Returns a float value. More...
 
tVoid SetSectionName (const cString &strSection)
 Sets the current section for the Section* methods. More...
 
cString GetSectionName () const
 Returns the current section name. More...
 
cString SectionGet (const cString &strName, const cString &strDefault="") const
 Returns a string value. More...
 
tBool SectionGetBool (const cString &strName, const tBool &bDefault=false) const
 Returns a bool value. More...
 
int SectionGetInt (const cString &strName, const int &iDefault=0) const
 Returns an integer value. More...
 
tFloat64 SectionGetFloat64 (const cString &strName, const tFloat64 &f64Default=0) const
 Returns a float value. More...
 

Protected Member Functions

cFilename LookupFile () const
 Returns the default filename. More...
 

Protected Attributes

cString m_strSection
 Internally used name of section.
 
cDOM m_oDoc
 Internally used DOM object.
 

Detailed Description

INI file handling.

Definition at line 18 of file inifile.h.

Member Function Documentation

◆ Exists()

tBool Exists ( const cString strSection,
const cString strName 
) const

Checks if an entry exists in the ini file.

Parameters
strSection[in] The section of the ini file.
strName[in] The name of the value.
Returns
tTrue if entry exists, otherwise tFalse

◆ Get()

cString Get ( const cString strSection,
const cString strName,
const cString strDefault = "" 
) const

Returns a string value.

Parameters
strSection[in] The section of the ini file.
strName[in] The name of the value.
strDefault[in] The default which is returned if the value does not exist.
Returns
The value.

◆ GetBool()

tBool GetBool ( const cString strSection,
const cString strName,
const tBool bDefault = false 
) const

Returns a bool value.

Parameters
strSection[in] The section of the ini file.
strName[in] The name of the value.
bDefault[in] The default which is returned if the value does not exist.
Returns
The value.

◆ GetFloat64()

tFloat64 GetFloat64 ( const cString strSection,
const cString strName,
const tFloat64 f64Default = 0 
) const

Returns a float value.

Parameters
strSection[in] The section of the ini file.
strName[in] The name of the value.
f64Default[in] The default which is returned if the value does not exist.
Returns
The value.

◆ GetInt()

int GetInt ( const cString strSection,
const cString strName,
const int &  iDefault = 0 
) const

Returns an integer value.

Parameters
strSection[in] The section of the ini file.
strName[in] The name of the value.
iDefault[in] The default which is returned if the value does not exist.
Returns
The value.

◆ GetSectionName()

cString GetSectionName ( ) const

Returns the current section name.

Returns
The current section name.

◆ Load()

tResult Load ( const cFilename strFilename = "",
const tBool bParse = tTrue 
)

Loads an INI file.

Parameters
strFilename[in] The filename, if empty than the class will lock for one based on the application name.
bParse[in] If true (default) the value of an item will be parsed. I.e.
will generate a linebreak. If false the value is taken as it is.
Returns
ERR_UNKNOWN File could not be opened.

◆ LookupFile()

cFilename LookupFile ( ) const
protected

Returns the default filename.

Returns
Default filename

◆ RemoveKey()

tResult RemoveKey ( const cString strSection,
const cString strName 
)

Removes a key from a section.

Parameters
strSection[in] the section that contains the key
strName[in] the key to remove
Returns
Standard result.

◆ RemoveSection()

tResult RemoveSection ( const cString strSection)

Removes an entire section.

Parameters
strSection[in] the name of the section to remove
Returns
Standard result.

◆ Save()

tResult Save ( const cFilename strFilename = "")

Saves an INI file.

Parameters
strFilename[in] The filename, if empty than the class will lock for one based on the application name.
Returns
ERR_UNKNOWN File could not be opened.

◆ SectionGet()

cString SectionGet ( const cString strName,
const cString strDefault = "" 
) const

Returns a string value.

Parameters
strName[in] The name of the value.
strDefault[in] The default which is returned if the value does not exist.
Returns
The value.

◆ SectionGetBool()

tBool SectionGetBool ( const cString strName,
const tBool bDefault = false 
) const

Returns a bool value.

Parameters
strName[in] The name of the value.
bDefault[in] The default which is returned if the value does not exist.
Returns
The value.

◆ SectionGetFloat64()

tFloat64 SectionGetFloat64 ( const cString strName,
const tFloat64 f64Default = 0 
) const

Returns a float value.

Parameters
strName[in] The name of the value.
f64Default[in] The default which is returned if the value does not exist.
Returns
The value.

◆ SectionGetInt()

int SectionGetInt ( const cString strName,
const int &  iDefault = 0 
) const

Returns an integer value.

Parameters
strName[in] The name of the value.
iDefault[in] The default which is returned if the value does not exist.
Returns
The value.

◆ Set()

tBool Set ( const cString strSection,
const cString strName,
const cString strValue = "" 
)

Sets a string value.

Parameters
strSection[in] The section of the ini file.
strName[in] The name of the value.
strValue[in] The value.
Returns
tTrue if successful, otherwise tFalse.

◆ SetBool()

tBool SetBool ( const cString strSection,
const cString strName,
const tBool bValue 
)

Sets a bool value.

Parameters
strSection[in] The section of the ini file.
strName[in] The name of the value.
bValue[in] The value.
Returns
tTrue if successful, otherwise tFalse.

◆ SetFloat64()

tBool SetFloat64 ( const cString strSection,
const cString strName,
const tFloat64 f64Value 
)

Sets a float value.

Parameters
strSection[in] The section of the ini file.
strName[in] The name of the value.
f64Value[in] The value.
Returns
tTrue if successful, otherwise tFalse.

◆ SetInt()

tBool SetInt ( const cString strSection,
const cString strName,
const int &  iValue 
)

Sets an integer value.

Parameters
strSection[in] The section of the ini file.
strName[in] The name of the value.
iValue[in] The value.
Returns
tTrue if successful, otherwise tFalse.

◆ SetSectionName()

tVoid SetSectionName ( const cString strSection)

Sets the current section for the Section* methods.

Parameters
strSection[in] The section.
Returns
void