Main Page   Class Hierarchy   Compound List   File List   Compound Members  

kconfigbackend.h

00001 // vi:ts=4:shiftwidth=4:expandtab
00002 /*
00003    This file is part of the KDE libraries
00004    Copyright (c) 1999 Preston Brown <pbrown@kde.org>
00005    Portions copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
00006    Copyright (C) 2002 Zhang Le <ejoy@users.sourceforge.net>
00007    Last Change:20-Jul-2002.
00008    
00009    This library is free software; you can redistribute it and/or
00010    modify it under the terms of the GNU Library General Public
00011    License as published by the Free Software Foundation; either
00012    version 2 of the License, or (at your option) any later version.
00013    
00014    This library is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017    Library General Public License for more details.
00018    
00019    You should have received a copy of the GNU Library General Public License
00020    along with this library; see the file COPYING.LIB.  If not, write to
00021    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022    Boston, MA 02111-1307, USA.
00023 */
00024 
00025 #ifndef _KCONFIGBACKEND_H
00026 #define _KCONFIGBACKEND_H
00027 
00028 #include "kconfigdata.h"
00029 #include "kconfigbase.h"
00030 
00031 namespace config {
00032 
00033 class KConfigBackEndPrivate;
00034 
00050 class KConfigBackEnd
00051 {
00052 public:
00068   KConfigBackEnd(KConfigBase *_config, const string &_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 string &_fileName, const char * _resType,
00106                       bool _useKDEGlobals);
00107 
00113   virtual KConfigBase::ConfigState getConfigState() const
00114     { return mConfigState; }
00115 
00119   string fileName() const { return mfileName; }
00120 
00124   const char * resource() const { return resType.c_str(); }
00125 
00126   void setLocaleString(const string &_localeString) { localeString = _localeString; }
00127 
00131   void setFileWriteMode(int mode);
00132 
00133 #ifdef KDE_NO_COMPAT
00134 private:
00135 #endif
00136 
00139   string filename() const { return mfileName; }
00140 
00141 
00142 protected:
00143   KConfigBase *pConfig;
00144 
00145   string mfileName;
00146   string resType;
00147   bool useKDEGlobals : 1;
00148   bool bFileImmutable : 1;
00149   string localeString;
00150   string mLocalFileName;
00151   string mGlobalFileName;
00152   KConfigBase::ConfigState mConfigState;
00153   int mFileMode;
00154 
00155 protected:
00156   virtual void virtual_hook( int id, void* data );
00157 private:
00158   KConfigBackEndPrivate *d;
00159 };
00160 
00161 class KConfigINIBackEndPrivate;
00162 
00170 class KConfigINIBackEnd : public KConfigBackEnd
00171 {
00172 
00173 public:
00189   KConfigINIBackEnd(KConfigBase *_config, const string &_fileName,
00190                     const char * _resType, bool _useKDEGlobals = true)
00191     : KConfigBackEnd(_config, _fileName, _resType, _useKDEGlobals) {}
00192 
00196   virtual ~KConfigINIBackEnd() {};
00197 
00203   bool parseConfigFiles();
00204 
00208   virtual void sync(bool bMerge = true);
00209 
00210 protected:
00226   void parseSingleConfigFile(string& rFile, KEntryMap *pWriteBackMap = 0L,
00227                              bool bGlobal = false, bool bDefault = false);
00228 
00243   bool writeConfigFile(string filename, bool bGlobal = false, bool bMerge = true);
00244 
00245 protected:
00246   virtual void virtual_hook( int id, void* data );
00247 private:
00248   KConfigINIBackEndPrivate *d;
00249 };
00250  }; //namespace config
00251 
00252 #endif

Generated on Sat Dec 14 20:05:52 2002 for libconfig by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002