kdecore Library API Documentation

kconfigbackend.h

00001 /*
00002    This file is part of the KDE libraries
00003    Copyright (c) 1999 Preston Brown <pbrown@kde.org>
00004    Portions copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.
00020 */
00021 
00022 #ifndef _KCONFIGBACKEND_H
00023 #define _KCONFIGBACKEND_H
00024 
00025 #include "kconfigdata.h"
00026 #include <kconfigbase.h>
00027 #include "kdemacros.h"
00028 
00029 class QFile;
00030 class KConfigBackEndPrivate;
00031 
00047 class KConfigBackEnd
00048 {
00049   friend class KConfig;
00050 public:
00066   KConfigBackEnd(KConfigBase *_config, const QString &_fileName,
00067          const char * _resType, bool _useKDEGlobals);
00068 
00072   virtual ~KConfigBackEnd();
00073 
00080   virtual bool parseConfigFiles() = 0;
00081 
00091   virtual void sync(bool bMerge = true) = 0;
00092 
00103   void changeFileName(const QString &_fileName, const char * _resType,
00104               bool _useKDEGlobals);
00105 
00111   virtual KConfigBase::ConfigState getConfigState() const
00112     { return mConfigState; }
00113 
00118   QString fileName() const { return mfileName; }
00119 
00124   const char * resource() const { return resType; }
00125 
00131   void setLocaleString(const QCString &_localeString) { localeString = _localeString; }
00132 
00137   void setFileWriteMode(int mode);
00138 
00145   bool checkConfigFilesWritable(bool warnUser);
00146 
00147 #ifdef KDE_NO_COMPAT
00148 private:
00149 #endif
00150 
00153   KDE_DEPRECATED QString filename() const { return mfileName; }
00154 
00155 
00156 protected:
00157   KConfigBase *pConfig;
00158 
00159   QString mfileName;
00160   QCString resType;
00161   bool useKDEGlobals : 1;
00162   bool bFileImmutable : 1;
00163   QCString localeString;
00164   QString mLocalFileName;
00165   QString mGlobalFileName;
00166   KConfigBase::ConfigState mConfigState;
00167   int mFileMode;
00168 
00169 protected:
00170   virtual void virtual_hook( int id, void* data );
00171 protected:
00172   class KConfigBackEndPrivate;
00173   KConfigBackEndPrivate *d;
00174 };
00175 
00176 class KConfigINIBackEndPrivate;
00177 
00185 class KConfigINIBackEnd : public KConfigBackEnd
00186 {
00187 
00188 public:
00204   KConfigINIBackEnd(KConfigBase *_config, const QString &_fileName,
00205             const char * _resType, bool _useKDEGlobals = true)
00206     : KConfigBackEnd(_config, _fileName, _resType, _useKDEGlobals) {}
00207 
00211   virtual ~KConfigINIBackEnd() {};
00212 
00218   bool parseConfigFiles();
00219 
00227   virtual void sync(bool bMerge = true);
00228 
00229 protected:
00245   void parseSingleConfigFile(QFile& rFile, KEntryMap *pWriteBackMap = 0L,
00246                  bool bGlobal = false, bool bDefault = false);
00247 
00262   bool writeConfigFile(QString filename, bool bGlobal = false, bool bMerge = true);
00263 
00276   bool getEntryMap(KEntryMap &map, bool bGlobal, QFile *mergeFile);
00277 
00279   void writeEntries(FILE *pStream, const KEntryMap &aTempMap);
00280 
00281 protected:
00282   virtual void virtual_hook( int id, void* data );
00283 private:
00284   KConfigINIBackEndPrivate *not_d;
00285 };
00286 
00287 #endif
KDE Logo
This file is part of the documentation for kdecore Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 3 19:22:47 2005 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003