Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /* |
---|---|
2 | This file is part of the KDE libraries |
3 | Copyright (c) 2006, 2007 Thomas Braxton <kde.braxton@gmail.com> |
4 | Copyright (c) 2001 Waldo Bastian <bastian@kde.org> |
5 | Copyright (c) 1999 Preston Brown <pbrown@kde.org> |
6 | Copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org> |
7 | |
8 | This library is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU Library General Public |
10 | License as published by the Free Software Foundation; either |
11 | version 2 of the License, or (at your option) any later version. |
12 | |
13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Library General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Library General Public License |
19 | along with this library; see the file COPYING.LIB. If not, write to |
20 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 | Boston, MA 02110-1301, USA. |
22 | */ |
23 | |
24 | #ifndef KCONFIGBASE_H |
25 | #define KCONFIGBASE_H |
26 | |
27 | #include <kdecore_export.h> |
28 | |
29 | #include <QtCore/QtGlobal> |
30 | |
31 | class QStringList; |
32 | class KConfigGroup; |
33 | class KConfigBasePrivate; |
34 | |
35 | /** |
36 | * \class KConfigBase kconfigbase.h <KConfigBase> |
37 | */ |
38 | class KDECORE_EXPORT KConfigBase |
39 | { |
40 | public: |
41 | /** |
42 | * Flags to control write entry |
43 | */ |
44 | enum WriteConfigFlag |
45 | { |
46 | Persistent = 0x01, |
47 | /**< |
48 | * Save this entry when saving the config object. |
49 | */ |
50 | Global = 0x02, |
51 | /**< |
52 | * Save the entry to the global %KDE config file instead of the |
53 | * application specific config file. |
54 | */ |
55 | Localized = 0x04, |
56 | /**< |
57 | * Add the locale tag to the key when writing it. |
58 | */ |
59 | Normal=Persistent |
60 | /**< |
61 | * Save the entry to the application specific config file without |
62 | * a locale tag. This is the default. |
63 | */ |
64 | |
65 | }; |
66 | Q_DECLARE_FLAGS(WriteConfigFlags, WriteConfigFlag) |
67 | |
68 | /** |
69 | * Destructs the KConfigBase object. |
70 | */ |
71 | virtual ~KConfigBase(); |
72 | |
73 | /** |
74 | * Returns a list of groups that are known about. |
75 | * |
76 | * @return The list of groups. |
77 | **/ |
78 | virtual QStringList groupList() const = 0; |
79 | |
80 | /** |
81 | * Returns true if the specified group is known about. |
82 | * |
83 | * @param group The group to search for. |
84 | * @return true if the group exists. |
85 | */ |
86 | bool hasGroup(const QString &group) const; |
87 | bool hasGroup(const char *group) const; |
88 | bool hasGroup(const QByteArray &group) const; |
89 | |
90 | /** |
91 | * Returns an object for the named subgroup. |
92 | * |
93 | * @param group the group to open. Pass a null string on to the KConfig |
94 | * object to obtain a handle on the root group. |
95 | * @return The list of groups. |
96 | **/ |
97 | KConfigGroup group(const QByteArray &group); |
98 | KConfigGroup group(const QString &group); |
99 | KConfigGroup group(const char *group); |
100 | |
101 | /** |
102 | * @overload |
103 | **/ |
104 | const KConfigGroup group(const QByteArray &group) const; |
105 | const KConfigGroup group(const QString &group) const; |
106 | const KConfigGroup group(const char *group) const; |
107 | |
108 | /** |
109 | * Delete @p aGroup. This marks @p aGroup as @em deleted in the config object. This effectively |
110 | * removes any cascaded values from config files earlier in the stack. |
111 | */ |
112 | void deleteGroup(const QByteArray &group, WriteConfigFlags flags = Normal); |
113 | void deleteGroup(const QString &group, WriteConfigFlags flags = Normal); |
114 | void deleteGroup(const char *group, WriteConfigFlags flags = Normal); |
115 | |
116 | /** |
117 | * Syncs the configuration object that this group belongs to. |
118 | * Unrelated concurrent changes to the same file are merged and thus |
119 | * not overwritten. Note however, that this object is @em not automatically |
120 | * updated with those changes. |
121 | */ |
122 | virtual void sync() = 0; |
123 | |
124 | /** |
125 | * Reset the dirty flags of all entries in the entry map, so the |
126 | * values will not be written to disk on a later call to sync(). |
127 | */ |
128 | virtual void markAsClean() = 0; |
129 | |
130 | /** |
131 | * Possible return values for accessMode(). |
132 | */ |
133 | enum AccessMode { NoAccess, ReadOnly, ReadWrite }; |
134 | |
135 | /** |
136 | * Returns the access mode of the app-config object. |
137 | * |
138 | * Possible return values |
139 | * are NoAccess (the application-specific config file could not be |
140 | * opened neither read-write nor read-only), ReadOnly (the |
141 | * application-specific config file is opened read-only, but not |
142 | * read-write) and ReadWrite (the application-specific config |
143 | * file is opened read-write). |
144 | * |
145 | * @return the access mode of the app-config object |
146 | */ |
147 | virtual AccessMode accessMode() const = 0; |
148 | |
149 | /** |
150 | * Checks whether this configuration object can be modified. |
151 | * @return whether changes may be made to this configuration object. |
152 | */ |
153 | virtual bool isImmutable() const = 0; |
154 | |
155 | /** |
156 | * Can changes be made to the entries in @p aGroup? |
157 | * |
158 | * @param aGroup The group to check for immutability. |
159 | * @return @c false if the entries in @p aGroup can be modified. |
160 | */ |
161 | bool isGroupImmutable(const QByteArray& aGroup) const; |
162 | bool isGroupImmutable(const QString& aGroup) const; |
163 | bool isGroupImmutable(const char *aGroup) const; |
164 | |
165 | protected: |
166 | KConfigBase(); |
167 | |
168 | virtual bool hasGroupImpl(const QByteArray &group) const = 0; |
169 | virtual KConfigGroup groupImpl( const QByteArray &b) = 0; |
170 | virtual const KConfigGroup groupImpl(const QByteArray &b) const = 0; |
171 | virtual void deleteGroupImpl(const QByteArray &group, WriteConfigFlags flags = Normal) = 0; |
172 | virtual bool isGroupImmutableImpl(const QByteArray& aGroup) const = 0; |
173 | |
174 | /** Virtual hook, used to add new "virtual" functions while maintaining |
175 | * binary compatibility. Unused in this class. |
176 | */ |
177 | virtual void virtual_hook( int id, void* data ); |
178 | }; |
179 | |
180 | Q_DECLARE_OPERATORS_FOR_FLAGS(KConfigBase::WriteConfigFlags) |
181 | |
182 | |
183 | |
184 | #endif // KCONFIG_H |
185 |
Warning: That file was not part of the compilation database. It may have many parsing errors.