• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • config
kconfigbackend.h
Go to the documentation of this file.
1/*
2 This file is part of the KDE libraries
3 Copyright (c) 2006, 2007 Thomas Braxton <kde.braxton@gmail.com>
4 Copyright (c) 1999 Preston Brown <pbrown@kde.org>
5 Portions copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22
23#ifndef KCONFIGBACKEND_H
24#define KCONFIGBACKEND_H
25
26#include <QtCore/QObject>
27#include <QtCore/QString>
28
29#include <kdecore_export.h>
30#include <kconfigbase.h>
31#include <kdebug.h>
32#ifndef KDE_NO_DEPRECATED
33#include <kgenericfactory.h>
34#endif
35#include <klocale.h>
36#include <kpluginfactory.h>
37#include <kpluginloader.h>
38#include <ksharedptr.h>
39
40class KEntryMap;
41class KComponentData;
42class QFile;
43class QByteArray;
44class QDateTime;
45
55class KDECORE_EXPORT KConfigBackend : public QObject, public KShared
56{
57 Q_OBJECT
58 Q_FLAGS(ParseOption)
59 Q_FLAGS(WriteOption)
60
61public:
73 static KSharedPtr<KConfigBackend> create(const KComponentData& componentData,
74 const QString& fileName = QString(),
75 const QString& system = QString());
76
87 static void registerMappings(const KEntryMap& entryMap);
88
90 virtual ~KConfigBackend();
91
93 enum ParseOption {
94 ParseGlobal = 1,
95 ParseDefaults = 2,
96 ParseExpansions = 4
97 };
99 Q_DECLARE_FLAGS(ParseOptions, ParseOption)
100
101
102 enum WriteOption {
103 WriteGlobal = 1
104 };
106 Q_DECLARE_FLAGS(WriteOptions, WriteOption)
107
108
109 enum ParseInfo {
110 ParseOk,
111 ParseImmutable,
112 ParseOpenError
113 };
114
123 virtual ParseInfo parseConfig(const QByteArray& locale,
124 KEntryMap& pWriteBackMap,
125 ParseOptions options = ParseOptions()) = 0;
126
137 virtual bool writeConfig(const QByteArray& locale, KEntryMap& entryMap,
138 WriteOptions options, const KComponentData &data) = 0;
139
145 virtual bool isWritable() const = 0;
155 virtual QString nonWritableErrorMessage() const = 0;
161 virtual KConfigBase::AccessMode accessMode() const = 0;
168 virtual void createEnclosing() = 0;
169
177 virtual void setFilePath(const QString& path) = 0;
178
182 virtual bool lock(const KComponentData& componentData) = 0;
186 virtual void unlock() = 0;
190 virtual bool isLocked() const = 0;
191
195 QDateTime lastModified() const;
197 QString filePath() const;
199 qint64 size() const;
200
201protected:
202 KConfigBackend();
203 void setLastModified(const QDateTime& dt);
204 void setSize(qint64 sz);
205 void setLocalFilePath(const QString& file);
206
207private:
208 class Private;
209 Private *const d;
210};
211
212Q_DECLARE_OPERATORS_FOR_FLAGS(KConfigBackend::ParseOptions)
213Q_DECLARE_OPERATORS_FOR_FLAGS(KConfigBackend::WriteOptions)
214
215
218#define K_EXPORT_KCONFIGBACKEND(libname, classname) \
219K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
220K_EXPORT_PLUGIN(factory("kconfigbackend_" #libname))
221
222
223#endif // KCONFIGBACKEND_H
KComponentData
Per component data.
Definition: kcomponentdata.h:47
KConfigBackend
Provides the implementation for accessing configuration sources.
Definition: kconfigbackend.h:56
KConfigBackend::writeConfig
virtual bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, WriteOptions options, const KComponentData &data)=0
Write the dirty entries to permanent storage.
KConfigBackend::isWritable
virtual bool isWritable() const =0
If isWritable() returns false, writeConfig() will always fail.
KConfigBackend::unlock
virtual void unlock()=0
Release the lock on the file.
KConfigBackend::WriteOption
WriteOption
Allows the behaviour of writeConfig() to be tuned.
Definition: kconfigbackend.h:102
KConfigBackend::lock
virtual bool lock(const KComponentData &componentData)=0
Lock the file.
KConfigBackend::ParseOption
ParseOption
Allows the behaviour of parseConfig() to be tuned.
Definition: kconfigbackend.h:93
KConfigBackend::ParseInfo
ParseInfo
Return value from parseConfig()
Definition: kconfigbackend.h:109
KConfigBackend::ParseOk
@ ParseOk
Definition: kconfigbackend.h:110
KConfigBackend::ParseImmutable
@ ParseImmutable
the configuration was opened read/write
Definition: kconfigbackend.h:111
KConfigBackend::accessMode
virtual KConfigBase::AccessMode accessMode() const =0
KConfigBackend::parseConfig
virtual ParseInfo parseConfig(const QByteArray &locale, KEntryMap &pWriteBackMap, ParseOptions options=ParseOptions())=0
Read persistent storage.
KConfigBackend::nonWritableErrorMessage
virtual QString nonWritableErrorMessage() const =0
When isWritable() returns false, return an error message to explain to the user why saving configurat...
KConfigBackend::createEnclosing
virtual void createEnclosing()=0
Create the enclosing object of the configuration object.
KConfigBackend::setFilePath
virtual void setFilePath(const QString &path)=0
Set the file path.
KConfigBackend::isLocked
virtual bool isLocked() const =0
KConfigBase::AccessMode
AccessMode
Possible return values for accessMode().
Definition: kconfigbase.h:133
KEntryMap
type specifying a map of entries (key,value pairs).
Definition: kconfigdata.h:153
KSharedPtr
Can be used to control the lifetime of an object that has derived QSharedData.
Definition: ksharedptr.h:64
KShared
QDateTime
QObject
QString
qint64
kconfigbase.h
kdebug.h
kdecore_export.h
kgenericfactory.h
klocale.h
kpluginfactory.h
kpluginloader.h
ksharedptr.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal