kconfigbackend.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _KCONFIGBACKEND_H
00023 #define _KCONFIGBACKEND_H
00024
00025 #include "kconfigdata.h"
00026 #include <kconfigbase.h>
00027 #include <klockfile.h>
00028 #include <klocale.h>
00029 #include "kdelibs_export.h"
00030
00031 class QFile;
00032 class KConfigBackEndPrivate;
00033
00048 class KDECORE_EXPORT KConfigBackEnd
00049 {
00050 friend class KConfig;
00051 friend class KSharedConfig;
00052 public:
00068 KConfigBackEnd(KConfigBase *_config, const QString &_fileName,
00069 const char * _resType, bool _useKDEGlobals);
00070
00074 virtual ~KConfigBackEnd();
00075
00082 virtual bool parseConfigFiles() = 0;
00083
00093 virtual void sync(bool bMerge = true) = 0;
00094
00105 void changeFileName(const QString &_fileName, const char * _resType,
00106 bool _useKDEGlobals);
00107
00113 virtual KConfigBase::ConfigState getConfigState() const
00114 { return mConfigState; }
00115
00120 QString fileName() const { return mfileName; }
00121
00126 const char * resource() const { return resType; }
00127
00133 void setLocaleString(const QCString &_localeString) { localeString = _localeString; }
00134
00139 void setFileWriteMode(int mode);
00140
00147 bool checkConfigFilesWritable(bool warnUser);
00148
00154 KLockFile::Ptr lockFile( bool bGlobal = false );
00155
00156 #ifdef KDE_NO_COMPAT
00157 private:
00158 #endif
00159
00162 KDE_DEPRECATED QString filename() const { return mfileName; }
00163
00164 protected:
00165 KConfigBase *pConfig;
00166
00167 QString mfileName;
00168 QCString resType;
00169 bool useKDEGlobals : 1;
00170 bool bFileImmutable : 1;
00171 QCString localeString;
00172 QString mLocalFileName;
00173 QString mGlobalFileName;
00174 KConfigBase::ConfigState mConfigState;
00175 int mFileMode;
00176
00177 protected:
00178 virtual void virtual_hook( int id, void* data );
00179 protected:
00180 class KConfigBackEndPrivate;
00181 KConfigBackEndPrivate *d;
00182 };
00183
00184
00191 class KDECORE_EXPORT KConfigINIBackEnd : public KConfigBackEnd
00192 {
00193
00194 public:
00210 KConfigINIBackEnd(KConfigBase *_config, const QString &_fileName,
00211 const char * _resType, bool _useKDEGlobals = true)
00212 : KConfigBackEnd(_config, _fileName, _resType, _useKDEGlobals) {}
00213
00217 virtual ~KConfigINIBackEnd() {};
00218
00224 bool parseConfigFiles();
00225
00233 virtual void sync(bool bMerge = true);
00234
00235 protected:
00251 void parseSingleConfigFile(QFile& rFile, KEntryMap *pWriteBackMap = 0L,
00252 bool bGlobal = false, bool bDefault = false);
00253
00254
00255
00256
00257 void translateKey(KLocale& locale, QCString currentGroup, QCString key);
00258
00273 bool writeConfigFile(QString filename, bool bGlobal = false, bool bMerge = true);
00274
00287 bool getEntryMap(KEntryMap &map, bool bGlobal, QFile *mergeFile);
00288
00290 void writeEntries(FILE *pStream, const KEntryMap &aTempMap);
00291
00292 protected:
00293 virtual void virtual_hook( int id, void* data );
00294 private:
00295 class KConfigINIBackEndPrivate;
00296 KConfigINIBackEndPrivate *not_d;
00297 };
00298
00299 #endif
|