![]() |
tuchulcha
0.10.1
Graphical Workflow Configuration Editor
|
Qt implementation for ParameterFile class. More...
#include <QParameterFile.h>
Public Member Functions | |
QParameterFile (QString fileName="") | |
default constructor More... | |
void | clear () |
clear content | |
void | erase (QString parameter) |
remove parameter from file | |
bool | isSet (QString parameter) const |
check if a given parameter has been set | |
void | load (QString fileName, QString encoding=QString()) |
load parameter file More... | |
bool | rename (QString oldPrefix, QString newPrefix) |
rename prefix More... | |
void | save (QString fileName) const |
save to given plain text file | |
QStringList | toStringList () const |
get StringList representation, like file content after save() | |
setters and getters | |
If parameter is unset, the getters return a null string. | |
void | set (QString parameter, QString value="") |
set parameter value More... | |
QString | get (QString parameter) const |
get parameter value More... | |
QStringList | getKeyList (QString beginsWith="") const |
Look for parameters beginning with a given string. More... | |
Static Public Attributes | |
static const QRegExp | paramCheck |
full parameter name check | |
static const QRegExp | paramCheckSloppy |
full parameter name check (sloppy version, may handle buggy lines) | |
static const QRegExp | postfixCheck |
postfix check, everything that may follow a prefix (starting with ".") | |
static const QRegExp | prefixCheck |
instance name or prefix check regex | |
Private Attributes | |
QHash< QString, QString > | _content |
value hash table, keys are stored in lowercase | |
QStringList | _keys |
key array, stored in mixed case | |
Hides unneeded complexity and provides QString getter and setter. New implementation based on Qt file-i/o and QTextStream to handle files with arbitrary encodings. Also supports keys with mixed case values. Parameter search is still done case-insensitive.
Definition at line 38 of file QParameterFile.h.
QParameterFile::QParameterFile | ( | QString | fileName = "" | ) |
[in] | fileName | file to load |
Definition at line 30 of file QParameterFile.cpp.
References load().
QString QParameterFile::get | ( | QString | parameter | ) | const |
parameter | parameter name (key) |
Definition at line 124 of file QParameterFile.cpp.
QStringList QParameterFile::getKeyList | ( | QString | beginsWith = "" | ) | const |
beginsWith | Beginning of parameter name |
Definition at line 162 of file QParameterFile.cpp.
References _keys.
void QParameterFile::load | ( | QString | fileName, |
QString | encoding = QString() |
||
) |
The file is interpreted as local 8-bit encoded. If specified, the given encoding is selected
fileName | path of file to read |
encoding | enfoce given encoding |
Definition at line 36 of file QParameterFile.cpp.
bool QParameterFile::rename | ( | QString | oldPrefix, |
QString | newPrefix | ||
) |
renames all keys starting with oldPrefix to ones with the given new prefix and also renames occurrences of the oldPrefix in values of other parameters (like slot connections)
The new prefix must match the rules for parameter file prefixes (as specified in QParameterFile::prefixCheck ). The old prefix is not checked, if there are dots, the part before the dots is used. In the worst case, there are no occurrences of an invalid keys which causes the function to return and skip the parameter renaming.
oldPrefix | old prefix |
newPrefix | new prefix (checks for valid prefix) |
true | renaming successful |
false | some error occured, nothing changed at all |
Definition at line 188 of file QParameterFile.cpp.
References _content, _keys, paramCheckSloppy, postfixCheck, and prefixCheck.
void QParameterFile::set | ( | QString | parameter, |
QString | value = "" |
||
) |
parameter | parameter (key), will be added if unset |
value | value to set |
Definition at line 147 of file QParameterFile.cpp.