Ini Class Reference

Configuration handler. More...

#include <ini.h>

+ Inheritance diagram for Ini:

Public Member Functions

 Ini (SettingsProvider *provider)
IniVariable createSetting (const QString &sectionname, const QString &name, const QVariant &data)
void deleteSection (const QString &sectionname)
void deleteSetting (const QString &sectionname, const QString &settingname)
bool hasSetting (const QString &sectionname, const QString &settingname) const
 true if setting of given name exists within given section. More...
void removeKey (const QString &key)
IniVariable retrieveSetting (const QString &sectionname, const QString &variablename)
IniSection section (const QString &name)
 Access configuration file section. More...
QVector< IniSectionsectionsArray (const QString &regexPattern)
IniVariable setting (const QString &sectionname, const QString &variablename)
void setValue (const QString &key, const QVariant &value)
QVariant value (const QString &key) const

Detailed Description

Configuration handler.

This class is an extension to simple interface provided by SettingsProvider.

This is wrapper provides a hierarchical access to the configuration. The hierarchy is resolved through the use of IniSection and IniVariable classes. The Ini class provides methods necessary to obtain valid instances of these objects.

Objects of IniSection and IniVariable classes can be copied over as they hold no actual data. They are used to generate valid paths and internally use methods provided by the Ini class objects that are associated with them. However, Ini object must remain valid when associated IniSection and IniVariable objects are in use or segmentation fault will occur.

Names of sections and variables are case sensitive.

The currently supported file format is:

[ section1 ]
var2="Exit game"
[ section2 ]
var2="New Game"

Definition at line 69 of file ini.h.

Member Function Documentation

IniVariable Ini::createSetting ( const QString &  sectionname,
const QString &  name,
const QVariant &  data 

Value of data parameter will be ignored and no changes will be performed if setting already exists.

Newly created or existing setting.

Definition at line 49 of file ini.cpp.

void Ini::deleteSection ( const QString &  sectionname)

Completely removes a given section.

Definition at line 60 of file ini.cpp.

void Ini::deleteSetting ( const QString &  sectionname,
const QString &  settingname 

Completely removes a given setting. This will not erase the section even if it's completely empty.

Definition at line 65 of file ini.cpp.

bool Ini::hasSetting ( const QString &  sectionname,
const QString &  settingname 
) const

true if setting of given name exists within given 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 70 of file ini.cpp.

IniVariable Ini::retrieveSetting ( const QString &  sectionname,
const QString &  variablename 

This won't create a variable if it doesn't exist and return NULL in such case.

A reference to the internally stored IniVariable if it does. Be sure to check if it isNull.

Definition at line 80 of file ini.cpp.

IniSection Ini::section ( const QString &  name)

Access configuration file section.

Creates and returns an accessor object to a section of specified name. No actual modification to underlying data is done. The IniSection object is merely a convenience proxy for the Ini class.

If section name is empty then a 'null object' of IniSection type is returned.

Definition at line 91 of file ini.cpp.

QVector< IniSection > Ini::sectionsArray ( const QString &  regexPattern)

Retrieves references to all sections whose names fit a certain pattern. Please remember that internally all sections are stored as lower-case strings. The regex pattern will be instructed to ignore the case size.

Definition at line 101 of file ini.cpp.

IniVariable Ini::setting ( const QString &  sectionname,
const QString &  variablename 

This method will create a variable if it doesn't exist. To avoid this behavior see:

See Also
Returns a pointer to a IniVariable object. Do not delete this object.

Definition at line 120 of file ini.cpp.

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