kconfigbackend.h
/*
This file is part of the KDE libraries
Copyright (c) 1999 Preston Brown <pbrown@kde.org>
Portions copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _KCONFIGBACKEND_H
#define _KCONFIGBACKEND_H
#include "kconfigdata.h"
#include <kconfigbase.h>
#include <klockfile.h>
#include "kdelibs_export.h"
class QFile;
class KConfigBackEndPrivate;
class KDECORE_EXPORT KConfigBackEnd
{
friend class KConfig;
friend class KSharedConfig;
public:
KConfigBackEnd(KConfigBase *_config, const QString &_fileName,
const char * _resType, bool _useKDEGlobals);
virtual ~KConfigBackEnd();
virtual bool parseConfigFiles() = 0;
virtual void sync(bool bMerge = true) = 0;
void changeFileName(const QString &_fileName, const char * _resType,
bool _useKDEGlobals);
virtual KConfigBase::ConfigState getConfigState() const
{ return mConfigState; }
QString fileName() const { return mfileName; }
const char * resource() const { return resType; }
void setLocaleString(const QCString &_localeString) { localeString = _localeString; }
void setFileWriteMode(int mode);
bool checkConfigFilesWritable(bool warnUser);
KLockFile::Ptr lockFile( bool bGlobal = false );
#ifdef KDE_NO_COMPAT
private:
#endif
KDE_DEPRECATED QString filename() const { return mfileName; }
protected:
KConfigBase *pConfig;
QString mfileName;
QCString resType;
bool useKDEGlobals : 1;
bool bFileImmutable : 1;
QCString localeString;
QString mLocalFileName;
QString mGlobalFileName;
KConfigBase::ConfigState mConfigState;
int mFileMode;
protected:
virtual void virtual_hook( int id, void* data );
protected:
class KConfigBackEndPrivate;
KConfigBackEndPrivate *d;
};
class KDECORE_EXPORT KConfigINIBackEnd : public KConfigBackEnd
{
public:
KConfigINIBackEnd(KConfigBase *_config, const QString &_fileName,
const char * _resType, bool _useKDEGlobals = true)
: KConfigBackEnd(_config, _fileName, _resType, _useKDEGlobals) {}
virtual ~KConfigINIBackEnd() {}
bool parseConfigFiles();
virtual void sync(bool bMerge = true);
protected:
void parseSingleConfigFile(QFile& rFile, KEntryMap *pWriteBackMap = 0L,
bool bGlobal = false, bool bDefault = false);
bool writeConfigFile(QString filename, bool bGlobal = false, bool bMerge = true);
bool getEntryMap(KEntryMap &map, bool bGlobal, QFile *mergeFile);
void writeEntries(FILE *pStream, const KEntryMap &aTempMap);
protected:
virtual void virtual_hook( int id, void* data );
private:
class KConfigINIBackEndPrivate;
KConfigINIBackEndPrivate *not_d;
};
#endif
KConfig::lockFile
KLockFile::Ptr lockFile(bool bGlobal=false)
Returns a lock file object for the configuration file or 0 if the backend does not support locking...
Definition: kconfig.cpp:280
KSharedPtr< KLockFile >
KConfigBackEnd::filename
KDE_DEPRECATED QString filename() const
Definition: kconfigbackend.h:161
KSharedConfig
KConfig variant using shared memory.
Definition: kconfig.h:273
KConfigBase::checkConfigFilesWritable
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
Definition: kconfigbase.cpp:1861
KConfigINIBackEnd::KConfigINIBackEnd
KConfigINIBackEnd(KConfigBase *_config, const QString &_fileName, const char *_resType, bool _useKDEGlobals=true)
Constructs an ini-style configuration back end.
Definition: kconfigbackend.h:209
KConfigBase::ConfigState
ConfigState
Possible return values for getConfigState().
Definition: kconfigbase.h:1804
KConfig::setFileWriteMode
void setFileWriteMode(int mode)
Set the file mode for newly created files.
Definition: kconfig.cpp:275
KConfigBase::sync
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage...
Definition: kconfigbase.cpp:1695
KConfigBackEnd::parseConfigFiles
virtual bool parseConfigFiles()=0
Parses all configuration files for a configuration object.
KConfigINIBackEnd::~KConfigINIBackEnd
virtual ~KConfigINIBackEnd()
Destructs the configuration backend.
Definition: kconfigbackend.h:216
KConfigBackEnd::setLocaleString
void setLocaleString(const QCString &_localeString)
Set the locale string that defines the current language.
Definition: kconfigbackend.h:132
KConfigBase::parseConfigFiles
virtual void parseConfigFiles()
Parses all configuration files for a configuration object.
Definition: kconfigbase.cpp:1683
KConfigINIBackEnd
Class for KDE INI-style configuration file loading/saving.
Definition: kconfigbackend.h:190
KConfigBase
KDE Configuration Management abstract base class.
Definition: kconfigbase.h:70
KConfigBackEnd::getConfigState
virtual KConfigBase::ConfigState getConfigState() const
Returns the state of the app-config object.
Definition: kconfigbackend.h:112
KConfigBackEnd
Abstract base class for KDE configuration file loading/saving.
Definition: kconfigbackend.h:47
KConfig
Access KDE Configuration entries.
Definition: kconfig.h:43
KConfigBackEnd::resource
const char * resource() const
Returns the resource type as passed to the constructor.
Definition: kconfigbackend.h:125
KConfigBackEnd::sync
virtual void sync(bool bMerge=true)=0
Writes configuration data to file(s).
KConfigBackEnd::fileName
QString fileName() const
Returns the filename as passed to the constructor.
Definition: kconfigbackend.h:119

KDE Home | KDE Accessibility Home | Description of Access Keys