00001 #ifndef __CONFIGFILE__H
00002 #define __CONFIGFILE__H
00003
00004 #include "mpdc.h"
00005
00006
00007 #include <qmap.h>
00008 #include <qstring.h>
00009 #include <qstringlist.h>
00010
00011 class ConfigFile
00012 {
00013 public:
00014 typedef QMap<QString, QString> ConfigGroup;
00015
00016 public:
00017 ConfigFile(const QString &fn);
00018 ~ConfigFile();
00019
00020 void setGroup(const QString &gname);
00021 void writeEntry(const QString &key, const QString &value);
00022 void writeEncryptedEntry(const QString &key, const QString &value);
00023 void writeEntry(const QString &key, int num);
00024 void writeEntry(const QString &key, bool b);
00025 void writeEntry(const QString &key, const QStringList &lst, const QChar &sep);
00026
00027 QString readEntry(const QString &key, const QString &deflt = QString::null);
00028 QString readEncryptedEntry(const QString &key, const QString &deflt = QString::null);
00029 int readNumEntry(const QString &key, int deflt = -1 );
00030 bool readBoolEntry(const QString &key, bool deflt = FALSE);
00031 QStringList readListEntry(const QString &key, const QChar &sep);
00032
00033 void clearGroup();
00034 void deleteGroup();
00035 status_t write(const QString &fn = QString::null);
00036
00037 protected:
00038 void read();
00039 void parse(const QString &line);
00040
00041 private:
00042 QMap<QString, ConfigGroup> groups;
00043 QMap<QString, ConfigGroup>::Iterator git;
00044 QString filename;
00045 };
00046
00047 #endif