fix logic
[personal-kdelibs.git] / kdecore / config / kconfigini_p.h
blobd7aa43ea0898e6438c1acfb1af4d22730c99c738
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>
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.
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.
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.
23 #ifndef KCONFIGINI_P_H
24 #define KCONFIGINI_P_H
26 #include <kdecore_export.h>
27 #include <kconfigbackend.h>
28 #include <klockfile.h>
30 class KConfigIniBackend : public KConfigBackend
32 private:
33 class BufferFragment;
35 KLockFile::Ptr lockFile;
36 public:
38 KConfigIniBackend();
39 ~KConfigIniBackend();
41 ParseInfo parseConfig(const QByteArray& locale,
42 KEntryMap& entryMap,
43 ParseOptions options);
44 ParseInfo parseConfig(const QByteArray& locale,
45 KEntryMap& entryMap,
46 ParseOptions options,
47 bool merging);
48 bool writeConfig(const QByteArray& locale, KEntryMap& entryMap,
49 WriteOptions options, const KComponentData &data);
51 bool isWritable() const;
52 QString nonWritableErrorMessage() const;
53 KConfigBase::AccessMode accessMode() const;
54 void createEnclosing();
55 void setFilePath(const QString& path);
56 bool lock(const KComponentData& componentData);
57 void unlock();
58 bool isLocked() const;
60 protected:
62 enum StringType {
63 GroupString = 0,
64 KeyString = 1,
65 ValueString = 2
67 // Warning: this modifies data in-place. Other BufferFragment objects referencing the same buffer
68 // fragment will get their data modified too.
69 static void printableToString(BufferFragment* aString, const QFile& file, int line);
70 static QByteArray stringToPrintable(const QByteArray& aString, StringType type);
71 static char charFromHex(const char *str, const QFile& file, int line);
72 static QString warningProlog(const QFile& file, int line);
74 void writeEntries(const QByteArray& locale, QFile& file, const KEntryMap& map);
75 void writeEntries(const QByteArray& locale, QFile& file, const KEntryMap& map,
76 bool defaultGroup, bool &firstEntry);
79 #endif // KCONFIGINI_P_H