#include <QY2Settings.h>
Public Types | |
enum | AccessMode { ReadOnly, ReadWrite, WriteOnly } |
Public Member Functions | |
QY2Settings (const QString &fileName, AccessMode accessMode=ReadOnly) | |
~QY2Settings () | |
bool | readError () const |
bool | readOk () const |
bool | selectSection (const QString §ion) |
void | selectDefaultSection () |
QString | currentSection () const |
QStringList | sections (bool includeUnnamed=false) const |
QString | get (const QString &key, const QString &fallback="") const |
QString | operator[] (const QString &key) |
bool | hasKey (const QString &key) |
QStringList | keys () const |
void | set (const QString &key, const QString &value) |
void | addSection (const QString §ion) |
void | clearSection () |
bool | save () |
bool | pendingChanges () const |
QString | fileName () const |
AccessMode | accessMode () const |
Protected Types | |
typedef QDictIterator< Section > | SectionIterator |
Protected Member Functions | |
void | initSections () |
bool | load () |
void | saveSection (QTextStream &stream, Section *section) |
Protected Attributes | |
QString | _fileName |
AccessMode | _accessMode |
bool | _readError |
QString | _currentSectionName |
Section * | _currentSection |
bool | _dirty |
Section * | _defaultSection |
QDict< Section > | _sections |
Classes | |
class | Section |
key="value" key2 = value ; comment # comment
[section-title] key = "value" ; comment key2="value" key3 = _( "message that needs to be translated" )
[section-title2] key="value" key2="value"
key=value pairs appear one on a line each. Leading and trailing whitespace is disregarded around both key and value. Value should be quoted (but doesn't need to). Quotes in value are escaped with \".
|
|
|
|
|
Constructor. Reads settings from the specified file. Use readError() or readOk() afterwards to check for read errors. |
|
Destructor. Writes any pending changes back to the file if there are any left if accessMode() is ReadWrite or WriteOnly. |
|
Returns the access mode - one of ReadOnly, ReadWrite, WriteOnly. |
|
Add a section with the specified name. If a section with that name already exists, it will only be selected and its old contents will remain untouched. In any case, this section becomes the current section. |
|
Clear all key=value pairs from the current section. |
|
Returns the name of the current section or QString::null if the default section is used. |
|
Returns the file name. |
|
Returns the value for the specified key in the current section. If there is no such key, the specified fallback value is returned. |
|
Checks if the current section has the specified key. |
|
Initialize the section data |
|
Returns a list of all keys in the current section. The list sort order is undefined. |
|
Read the settings file. Sets _readError depending on success or failure. Returns 'true' upon success. |
|
Same as get() with fallback always an empty string |
|
Returns 'true' if there are any changes that need to be written. Always returns 'false' if accessMode() is ReadOnly. |
|
Returns 'true' if the settings couldn't be read from the file specified in the constructor. |
|
Returns 'true' if the settings were read without problems from the file specified in the constructor. This is simply the opposite of readError(). |
|
Writes changed settings back to the file specified in the constructor if accessMode() is ReadWrite or WriteOnly. Returns 'true' on success. |
|
Save one section to a stream |
|
Returns a list of all sections. 'includeUnnamed' specifies if the unnamed default section should be included in the list. The list sort order is undefined. |
|
Select the default (unnamed) section for subsequent get() calls. This is the default unless selectSection() was called. |
|
Select the specified section in the settings for subsequent get() calls. Until is used, the unnamed default section is used. In the settings file, a section is marked with [section-title] Using a null string (QString::null) switches back to the unnamed default section. Returns 'true' upon success, 'false' if there is no such section (in which case the unnamed default section will be selected). |
|
Set the specified key to the specified value. Overwrites any existing key-value pair or adds a new one if there is no such key yet. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|