00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef TEINIFILE_H
00032 #define TEINIFILE_H
00033
00034 #include <qvariant.h>
00035 #include <qwidget.h>
00036 #include <qfile.h>
00037 #include <qstring.h>
00038 #include <qstringlist.h>
00039 #include <qtextstream.h>
00040 #include <qmap.h>
00041 #include <qcolor.h>
00042 #include <qrect.h>
00043 #include "teglobal.h"
00044
00045 typedef QMap<QString, QString> type_ValueList;
00046 typedef QMapIterator<QString, QString> type_ValueListIterator;
00047
00048 #include "templexports.h"
00049
00050 class LIB_EXPORT TEIniFile
00051 {
00052 public:
00053 TEIniFile(const QString &name = QString::null);
00054 ~TEIniFile();
00055
00056 void setFileName(const QString &name);
00057 bool openWrite();
00058 bool openRead();
00059 void close();
00060
00061 void writeBreak();
00062 void writeSection(const QString §ion);
00063 void writeComment(const QString &comment);
00064 void writeString(const QString &name, const QString &value);
00065 void writeData(const QString &name, const QString &value);
00066 void writeNumber(const QString &name, const int value, const int base = 10);
00067 void writeStringList(const QString &name, const QStringList &value);
00068 void writeDataList(const QString &name, const QStringList &value);
00069 void writeBool(const QString &name, const bool value);
00070 void writeColor(const QString &name, const QColor& color);
00071 void writeRect(const QString &name, const QRect& rect);
00072
00073 bool sectionExists(const QString §ion)
00074 { return SectionList.contains(section); }
00075 bool useSection(const QString §ion);
00076 const QString& readString(const QString &name, const QString &def = QString::null);
00077 int readNumber(const QString &name, const int def = 0, const int base = 10);
00078 bool readBool(const QString &name, const bool def = false);
00079 const QColor& readColor(const QString &name, const QColor& def = QColor());
00080 const QRect& readRect(const QString &name, const QRect& def = QRect());
00081
00082 void setString(const QString &name, const QString &value);
00083 void setData(const QString &name, const QString &value);
00084 void setNumber(const QString &name, const int value, const int base = 10);
00085 void setStringList(const QString &name, const QStringList &value);
00086 void setDataList(const QString &name, const QStringList &value);
00087 void setBool(const QString &name, const bool value);
00088 void setColor(const QString &name, const QColor& color);
00089 void setRect(const QString &name, const QRect& rect);
00090
00092 void deleteName(const QString &name);
00093
00094 bool isNameExists(const QString &name);
00095
00096 bool getString(const QString & name, QString & value);
00097
00098 bool getNumber(const QString & name, int & value, const int base=10);
00099 bool getBool(const QString & name, bool & value);
00100
00101 bool update();
00102
00103 QStringList usedValues();
00104 protected:
00105 QTextStream ts;
00106 QFile f;
00107 QMap<QString, type_ValueList> SectionList;
00108 QMap<QString, type_ValueList> SectionListDef;
00109 QMapIterator<QString, type_ValueList> mi;
00110 QString m_sCurSection;
00111 bool m_break;
00112 };
00113
00114 #endif