classConfig.html
Config Class Reference
#include <config.h>
Public Types | |
typedef QMap< QString, QString > | ConfigGroup |
Public Member Functions | |
Config (const QString &fn) | |
void | setGroup (const QString &gname) |
void | writeEntry (const QString &key, const QString &value) |
void | writeEntry (const QString &key, int num) |
void | writeEntry (const QString &key, double num) |
void | writeEntry (const QString &key, bool b) |
void | writeEntry (const QString &key, const QStringList &lst, const QChar &sep) |
QString | readEntry (const QString &key, const QString &deflt=QString::null) |
int | readNumEntry (const QString &key, int deflt=-1) |
double | readNumEntry (const QString &key, double deflt=0.0) |
bool | readBoolEntry (const QString &key, bool deflt=FALSE) |
QStringList | readListEntry (const QString &key, const QChar &sep) |
void | removeGroup (const QString &gp) |
void | removeEntry (const QString &key) |
void | clearGroup () |
bool | write (const QString &fn=QString::null) |
bool | ok () |
Protected Member Functions | |
bool | read () |
void | parse (const QString &line) |
Protected Attributes | |
QMap< QString, ConfigGroup > | groups |
QMap< QString, ConfigGroup >::Iterator | git |
QString | filename |
bool | m_bOk |
bool | m_bChanged |
Detailed Description
Reads & writes a config fileThis is a modified version of the config.h from qt designer.
The file lookes like this: [group1] value1 = ... value2 = ... [group2] value1 = ... value2 = ... ...
Example: bool myClass::saveDialogSettings(const QString &filename) { Config ConfigFile(filename); if (ConfigFile.ok()) { ConfigFile.setGroup("DialogSettings");
ConfigFile.writeEntry("x", pos().x()); ConfigFile.writeEntry("y", pos().y()); ConfigFile.writeEntry("width", size().width()); ConfigFile.writeEntry("height", size().height());
return ConfigFile.write(); } else return false; }
- Version:
- 1.0 Changes:
- bool ok() added.
- void removeGroup(...) added.
- void removeEntry(...) added.
- double readNumEntry(...) added.
- void writeEntry(..., double num) added.
- The file is now only written if writeEntry is called at least once.
Member Function Documentation
|
Clears the current group, does nothing if no group is set. Use removeGroup to remove the group itself;
|
|
Parces a single line |
|
Reads the entire file speciefied in the constructor. Returns false if the file does not exist or the file can't be opened by some reason. Note: Prints out qWarnings if an error occurs in debug mode |
|
Removes the entry "key" from the current group. Does nothing if no group is set or the entry is not existing.
|
|
Removes the group "grp" from the group list.
|
|
Writes by the default the file specified in the constructor if no attribute is used, otherwise it writes the file "fn". Return true and does nothing if we have not used any writeEntry function except we write to a different file then orignialy opened. setGroup alone does nothing, so its not possible to make an empty group or overwrite an file that has been read only during operation. |
The documentation for this class was generated from the following files:
- config.h
- config.cpp
Generated on Thu Nov 25 15:57:06 2004 for iARS(internetAudioRenderingSystem) by 1.3.9.1