classConfig.html

Config Class Reference

#include <config.h>

List of all members.


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 file

This 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

void Config::clearGroup  ) 
 

Clears the current group, does nothing if no group is set. Use removeGroup to remove the group itself;

See also:
removeEntry, removeGroup

void Config::parse const QString &  l  )  [protected]
 

Parces a single line

bool Config::read  )  [protected]
 

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

void Config::removeEntry const QString &  key  ) 
 

Removes the entry "key" from the current group. Does nothing if no group is set or the entry is not existing.

See also:
removeGroup, clearGroup

void Config::removeGroup const QString &  grp  ) 
 

Removes the group "grp" from the group list.

See also:
removeEntry, clearGroup

bool Config::write const QString &  fn = QString::null  ) 
 

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:
Generated on Thu Nov 25 15:57:06 2004 for iARS(internetAudioRenderingSystem) by  doxygen 1.3.9.1