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 
00028 class QFile;
00029 class KConfigBackEndPrivate;
00030 
00046 class KConfigBackEnd
00047 {
00048 public:
00064   KConfigBackEnd(KConfigBase *_config, const QString &_fileName,
00065                  const char * _resType, bool _useKDEGlobals);
00066 
00070   virtual ~KConfigBackEnd() {};
00071 
00078   virtual bool parseConfigFiles() = 0;
00079 
00089   virtual void sync(bool bMerge = true) = 0;
00090 
00101   void changeFileName(const QString &_fileName, const char * _resType,
00102                       bool _useKDEGlobals);
00103 
00109   virtual KConfigBase::ConfigState getConfigState() const
00110     { return mConfigState; }
00111 
00116   QString fileName() const { return mfileName; }
00117 
00122   const char * resource() const { return resType; }
00123 
00129   void setLocaleString(const QCString &_localeString) { localeString = _localeString; }
00130 
00135   void setFileWriteMode(int mode);
00136 
00137 #ifdef KDE_NO_COMPAT
00138 private:
00139 #endif
00140 
00143   QString filename() const { return mfileName; }
00144 
00145 
00146 protected:
00147   KConfigBase *pConfig;
00148 
00149   QString mfileName;
00150   QCString resType;
00151   bool useKDEGlobals : 1;
00152   bool bFileImmutable : 1;
00153   QCString localeString;
00154   QString mLocalFileName;
00155   QString mGlobalFileName;
00156   KConfigBase::ConfigState mConfigState;
00157   int mFileMode;
00158 
00159 protected:
00160   virtual void virtual_hook( int id, void* data );
00161 private:
00162   KConfigBackEndPrivate *d;
00163 };
00164 
00165 class KConfigINIBackEndPrivate;
00166 
00174 class KConfigINIBackEnd : public KConfigBackEnd
00175 {
00176 
00177 public:
00193   KConfigINIBackEnd(KConfigBase *_config, const QString &_fileName,
00194                     const char * _resType, bool _useKDEGlobals = true)
00195     : KConfigBackEnd(_config, _fileName, _resType, _useKDEGlobals) {}
00196 
00200   virtual ~KConfigINIBackEnd() {};
00201 
00207   bool parseConfigFiles();
00208 
00216   virtual void sync(bool bMerge = true);
00217 
00218 protected:
00234   void parseSingleConfigFile(QFile& rFile, KEntryMap *pWriteBackMap = 0L,
00235                              bool bGlobal = false, bool bDefault = false);
00236 
00251   bool writeConfigFile(QString filename, bool bGlobal = false, bool bMerge = true);
00252 
00253 protected:
00254   virtual void virtual_hook( int id, void* data );
00255 private:
00256   KConfigINIBackEndPrivate *d;
00257 };
00258 
00259 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:46:23 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001