IniSection Class Reference

INI section representation. More...

#include <inisection.h>

Public Member Functions

 IniSection ()
 Creates an invalid IniSection object. Such object should not be used for read/write operations. More...
 
 IniSection (Ini *pIni, const QString &sectionName)
 Creates a valid IniSection object. More...
 
IniVariable createSetting (const QString &name, const QVariant &data)
 Inits specified variable with specified data. More...
 
void deleteSetting (const QString &name)
 Deletes specified variable. More...
 
bool hasSetting (const QString &name) const
 true if setting of given name exists within the section. More...
 
bool isNull () const
 If true, IniSection object is not valid and should not be used to perform any actions on the Ini file. More...
 
const QString & name () const
 A name (or path) of this section with lettercase preserved. More...
 
IniVariable operator[] (const QString &name)
 Calls setting(). More...
 
const IniVariable operator[] (const QString &name) const
 Calls const retrieveSetting(). More...
 
IniVariable retrieveSetting (const QString &name)
 Gets a variable but only if it already exists. More...
 
const IniVariable retrieveSetting (const QString &name) const
 const version of retrieveSetting() More...
 
IniVariable setting (const QString &name)
 Gets a variable. Creates it first if it doesn't exist yet. More...
 
void setValue (const QString &key, const QVariant &value)
 Sets a variable directly. Omits the IniVariable system. More...
 
QVariant value (const QString &key) const
 Retrieves a variable directly; omits the IniVariable system. More...
 
QVariant value (const QString &key, QVariant defaultValue) const
 Retrieves a variable directly; omits the IniVariable system. More...
 

Detailed Description

INI section representation.

Provides access to variables in specified INI file section.

Definition at line 40 of file inisection.h.

Constructor & Destructor Documentation

IniSection::IniSection ( )

Creates an invalid IniSection object. Such object should not be used for read/write operations.

IniSection::IniSection ( Ini pIni,
const QString &  sectionName 
)

Creates a valid IniSection object.

IniSection object will operate on specified Ini object and provide access to variables in specified section.

Parameters
pIniPointer to Ini object on which this object will operate on. pIni is not deleted when this is deleted. pIni pointer is copied over when this is copied over.
sectionNameName of the section for which the variables will be accessed.

Definition at line 47 of file inisection.cpp.

Member Function Documentation

IniVariable IniSection::createSetting ( const QString &  name,
const QVariant &  data 
)

Inits specified variable with specified data.

This method serves specifically for init purposes. If variable exists already exists, data will not be modified.

Parameters
nameName of the variable to init. If '/' character is used, a variable in subsection will be accessed.
dataInit data. This data will be assigned to variable if specified variable doesn't yet exist.
Returns
IniVariable object that wraps around specified variable. A valid IniVariable object is returned both if variable was just created or already existed when createSetting() was called. IniVariable object is created by a call to retrieveSetting(). Invalid IniVariable is created if name is empty.

Definition at line 57 of file inisection.cpp.

void IniSection::deleteSetting ( const QString &  name)

Deletes specified variable.

Parameters
nameName of the variable to init. If '/' character is used, a variable in subsection will be accessed.

Definition at line 73 of file inisection.cpp.

bool IniSection::hasSetting ( const QString &  name) const

true if setting of given name exists within the section.

Setting contents may be empty and this will still return true. false is returned only if setting doesn't exist at all.

Definition at line 84 of file inisection.cpp.

bool IniSection::isNull ( ) const

If true, IniSection object is not valid and should not be used to perform any actions on the Ini file.

Definition at line 90 of file inisection.cpp.

const QString & IniSection::name ( ) const

A name (or path) of this section with lettercase preserved.

Definition at line 95 of file inisection.cpp.

IniVariable IniSection::operator[] ( const QString &  name)

Calls setting().

Definition at line 100 of file inisection.cpp.

const IniVariable IniSection::operator[] ( const QString &  name) const

Calls const retrieveSetting().

Definition at line 105 of file inisection.cpp.

IniVariable IniSection::retrieveSetting ( const QString &  name)

Gets a variable but only if it already exists.

Parameters
nameName of the variable to init. If '/' character is used, a variable in subsection will be accessed.
Returns
IniVariable object that wraps around the variable. May be invalid if name is empty.

Definition at line 115 of file inisection.cpp.

const IniVariable IniSection::retrieveSetting ( const QString &  name) const

const version of retrieveSetting()

Definition at line 126 of file inisection.cpp.

IniVariable IniSection::setting ( const QString &  name)

Gets a variable. Creates it first if it doesn't exist yet.

Parameters
nameName of the variable to init. If '/' character is used, a variable in subsection will be accessed.
Returns
IniVariable object that wraps around the variable. May be invalid if name is empty.

Definition at line 137 of file inisection.cpp.

void IniSection::setValue ( const QString &  key,
const QVariant &  value 
)

Sets a variable directly. Omits the IniVariable system.

Parameters
keyPath to the variable name. May include subsections by using '/' character.
valueNew value for the variable.

Definition at line 154 of file inisection.cpp.

QVariant IniSection::value ( const QString &  key) const

Retrieves a variable directly; omits the IniVariable system.

Returns
QVariant object that denotes the variable. May be invalid if variable is not defined.

Definition at line 164 of file inisection.cpp.

QVariant IniSection::value ( const QString &  key,
QVariant  defaultValue 
) const

Retrieves a variable directly; omits the IniVariable system.

Overload that returns defaultValue if requested value is invalid.

Returns
QVariant object that denotes the variable. If variable is not valid, the defaultValue is returned.

Definition at line 174 of file inisection.cpp.


The documentation for this class was generated from the following files: