tuchulcha  0.10.1
Graphical Workflow Configuration Editor
QParameterFile Class Reference

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
 

Detailed Description

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.

Constructor & Destructor Documentation

QParameterFile::QParameterFile ( QString  fileName = "")
Parameters
[in]fileNamefile to load

Definition at line 30 of file QParameterFile.cpp.

References load().

Member Function Documentation

QString QParameterFile::get ( QString  parameter) const
Parameters
parameterparameter name (key)
Returns
null string if unset

Definition at line 124 of file QParameterFile.cpp.

References _content, and isSet().

QStringList QParameterFile::getKeyList ( QString  beginsWith = "") const
Parameters
beginsWithBeginning of parameter name
Returns
matching keys

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

Parameters
fileNamepath of file to read
encodingenfoce given encoding

Definition at line 36 of file QParameterFile.cpp.

References _content, _keys, and set().

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.

Parameters
oldPrefixold prefix
newPrefixnew prefix (checks for valid prefix)
Return values
truerenaming successful
falsesome 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 = "" 
)
Parameters
parameterparameter (key), will be added if unset
valuevalue to set

Definition at line 147 of file QParameterFile.cpp.

References _content, _keys, and isSet().


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