Configuration handler. More...
#include <ini.h>
Public Member Functions | |
Ini (SettingsProvider *provider) | |
IniVariable | createSetting (const QString §ionname, const QString &name, const QVariant &data) |
void | deleteSection (const QString §ionname) |
void | deleteSetting (const QString §ionname, const QString &settingname) |
bool | hasSetting (const QString §ionname, const QString &settingname) const |
true if setting of given name exists within given section. More... | |
void | removeKey (const QString &key) |
IniVariable | retrieveSetting (const QString §ionname, const QString &variablename) |
IniSection | section (const QString &name) |
Access configuration file section. More... | |
QVector< IniSection > | sectionsArray (const QString ®exPattern) |
IniVariable | setting (const QString §ionname, const QString &variablename) |
void | setValue (const QString &key, const QVariant &value) |
QVariant | value (const QString &key) const |
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:
IniVariable Ini::createSetting | ( | const QString & | sectionname, |
const QString & | name, | ||
const QVariant & | data | ||
) |
void Ini::deleteSection | ( | const QString & | sectionname | ) |
void Ini::deleteSetting | ( | const QString & | sectionname, |
const QString & | settingname | ||
) |
bool Ini::hasSetting | ( | const QString & | sectionname, |
const QString & | settingname | ||
) | const |
IniVariable Ini::retrieveSetting | ( | const QString & | sectionname, |
const QString & | variablename | ||
) |
This won't create a variable if it doesn't exist and return nullptr in such case.
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.
QVector< IniSection > Ini::sectionsArray | ( | const QString & | regexPattern | ) |
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: