23#ifndef _TDECONFIGBASE_H
24#define _TDECONFIGBASE_H
29#include <tqdatetime.h>
31#include <tqstringlist.h>
35#include "tdeconfigdata.h"
36#include "tdelibs_export.h"
39class TDEConfigBasePrivate;
100 void setGroup(
const TQString& group );
106 void setDesktopGroup();
114 TQString group()
const;
122 bool hasGroup(
const TQString &group)
const;
136 TQString locale()
const;
146 TQString readEntry(
const TQString& pKey,
147 const TQString& aDefault = TQString::null )
const;
156 TQString readEntry(
const char *pKey,
157 const TQString& aDefault = TQString::null )
const;
172 TQVariant readPropertyEntry(
const TQString& pKey, TQVariant::Type )
const;
188 TQVariant readPropertyEntry(
const char *pKey, TQVariant::Type )
const;
204 TQVariant readPropertyEntry(
const TQString& pKey,
205 const TQVariant &aDefault)
const;
221 TQVariant readPropertyEntry(
const char *pKey,
222 const TQVariant &aDefault)
const;
234 int readListEntry(
const TQString& pKey, TQStrList &list,
char sep =
',' )
const;
246 int readListEntry(
const char *pKey, TQStrList &list,
char sep =
',' )
const;
255 TQStringList readListEntry(
const TQString& pKey,
char sep =
',' )
const;
264 TQStringList readListEntry(
const char *pKey,
char sep =
',' )
const;
275 TQStringList readListEntry(
const char* pKey,
const TQStringList& aDefault,
276 char sep =
',' )
const;
284 TQValueList<int> readIntListEntry(
const TQString& pKey )
const;
292 TQValueList<int> readIntListEntry(
const char *pKey )
const;
305 TQString readPathEntry(
const TQString& pKey,
const TQString & aDefault = TQString::null )
const;
318 TQString readPathEntry(
const char *pKey,
const TQString & aDefault = TQString::null )
const;
332 TQStringList readPathListEntry(
const TQString& pKey,
char sep =
',' )
const;
346 TQStringList readPathListEntry(
const char *pKey,
char sep =
',' )
const;
360 int readNumEntry(
const TQString& pKey,
int nDefault = 0 )
const;
373 int readNumEntry(
const char *pKey,
int nDefault = 0 )
const;
386 unsigned int readUnsignedNumEntry(
const TQString& pKey,
unsigned int nDefault = 0 )
const;
399 unsigned int readUnsignedNumEntry(
const char *pKey,
unsigned int nDefault = 0 )
const;
413 long readLongNumEntry(
const TQString& pKey,
long nDefault = 0 )
const;
426 long readLongNumEntry(
const char *pKey,
long nDefault = 0 )
const;
439 unsigned long readUnsignedLongNumEntry(
const TQString& pKey,
unsigned long nDefault = 0 )
const;
452 unsigned long readUnsignedLongNumEntry(
const char *pKey,
unsigned long nDefault = 0 )
const;
465 TQ_INT64 readNum64Entry(
const TQString& pKey, TQ_INT64 nDefault = 0 )
const;
478 TQ_INT64 readNum64Entry(
const char *pKey, TQ_INT64 nDefault = 0 )
const;
491 TQ_UINT64 readUnsignedNum64Entry(
const TQString& pKey, TQ_UINT64 nDefault = 0 )
const;
504 TQ_UINT64 readUnsignedNum64Entry(
const char *pKey, TQ_UINT64 nDefault = 0 )
const;
517 double readDoubleNumEntry(
const TQString& pKey,
double nDefault = 0.0 )
const;
530 double readDoubleNumEntry(
const char *pKey,
double nDefault = 0.0 )
const;
543 TQFont readFontEntry(
const TQString& pKey,
const TQFont* pDefault =
nullptr )
const;
556 TQFont readFontEntry(
const char *pKey,
const TQFont* pDefault =
nullptr )
const;
569 bool readBoolEntry(
const TQString& pKey,
bool bDefault =
false )
const;
582 bool readBoolEntry(
const char *pKey,
bool bDefault =
false )
const;
595 TQRect readRectEntry(
const TQString& pKey,
const TQRect* pDefault =
nullptr )
const;
608 TQRect readRectEntry(
const char *pKey,
const TQRect* pDefault =
nullptr )
const;
621 TQPoint readPointEntry(
const TQString& pKey,
const TQPoint* pDefault =
nullptr )
const;
634 TQPoint readPointEntry(
const char *pKey,
const TQPoint* pDefault =
nullptr )
const;
647 TQSize readSizeEntry(
const TQString& pKey,
const TQSize* pDefault =
nullptr )
const;
660 TQSize readSizeEntry(
const char *pKey,
const TQSize* pDefault =
nullptr )
const;
674 TQColor readColorEntry(
const TQString& pKey,
const TQColor* pDefault =
nullptr )
const;
687 TQColor readColorEntry(
const char *pKey,
const TQColor* pDefault =
nullptr )
const;
701 TQDateTime readDateTimeEntry(
const TQString& pKey,
const TQDateTime* pDefault =
nullptr )
const;
715 TQDateTime readDateTimeEntry(
const char *pKey,
const TQDateTime* pDefault =
nullptr )
const;
725 TQString readEntryUntranslated(
const TQString& pKey,
726 const TQString& aDefault = TQString::null )
const;
736 TQString readEntryUntranslated(
const char *pKey,
737 const TQString& aDefault = TQString::null )
const;
758 void writeEntry(
const TQString& pKey,
const TQString& pValue,
759 bool bPersistent =
true,
bool bGlobal =
false,
779 void writeEntry(
const char *pKey,
const TQString& pValue,
780 bool bPersistent =
true,
bool bGlobal =
false,
802 void writeEntry(
const TQString& pKey,
const TQVariant& rValue,
803 bool bPersistent =
true,
bool bGlobal =
false,
824 void writeEntry(
const char *pKey,
const TQVariant& rValue,
825 bool bPersistent =
true,
bool bGlobal =
false,
848 void writeEntry(
const TQString& pKey,
const TQStrList &rValue,
849 char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
870 void writeEntry(
const char *pKey,
const TQStrList &rValue,
871 char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
893 void writeEntry(
const TQString& pKey,
const TQStringList &rValue,
894 char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
915 void writeEntry(
const char *pKey,
const TQStringList &rValue,
916 char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
938 void writeEntry(
const TQString& pKey,
const TQValueList<int>& rValue,
939 bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
959 void writeEntry(
const char *pKey,
const TQValueList<int>& rValue,
960 bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
980 bool bPersistent =
true,
bool bGlobal =
false,
982 { writeEntry(pKey, TQString::fromLatin1(pValue), bPersistent, bGlobal, bNLS); }
1001 bool bPersistent =
true,
bool bGlobal =
false,
1003 { writeEntry(pKey, TQString::fromLatin1(pValue), bPersistent, bGlobal, bNLS); }
1020 void writeEntry(
const TQString& pKey,
int nValue,
1021 bool bPersistent =
true,
bool bGlobal =
false,
1022 bool bNLS =
false );
1038 void writeEntry(
const char *pKey,
int nValue,
1039 bool bPersistent =
true,
bool bGlobal =
false,
1040 bool bNLS =
false );
1057 void writeEntry(
const TQString& pKey,
unsigned int nValue,
1058 bool bPersistent =
true,
bool bGlobal =
false,
1059 bool bNLS =
false );
1075 void writeEntry(
const char *pKey,
unsigned int nValue,
1076 bool bPersistent =
true,
bool bGlobal =
false,
1077 bool bNLS =
false );
1093 void writeEntry(
const TQString& pKey,
long nValue,
1094 bool bPersistent =
true,
bool bGlobal =
false,
1095 bool bNLS =
false );
1110 void writeEntry(
const char *pKey,
long nValue,
1111 bool bPersistent =
true,
bool bGlobal =
false,
1112 bool bNLS =
false );
1128 void writeEntry(
const TQString& pKey,
unsigned long nValue,
1129 bool bPersistent =
true,
bool bGlobal =
false,
1130 bool bNLS =
false );
1145 void writeEntry(
const char *pKey,
unsigned long nValue,
1146 bool bPersistent =
true,
bool bGlobal =
false,
1147 bool bNLS =
false );
1163 void writeEntry(
const TQString& pKey, TQ_INT64 nValue,
1164 bool bPersistent =
true,
bool bGlobal =
false,
1165 bool bNLS =
false );
1180 void writeEntry(
const char *pKey, TQ_INT64 nValue,
1181 bool bPersistent =
true,
bool bGlobal =
false,
1182 bool bNLS =
false );
1198 void writeEntry(
const TQString& pKey, TQ_UINT64 nValue,
1199 bool bPersistent =
true,
bool bGlobal =
false,
1200 bool bNLS =
false );
1215 void writeEntry(
const char *pKey, TQ_UINT64 nValue,
1216 bool bPersistent =
true,
bool bGlobal =
false,
1217 bool bNLS =
false );
1236 void writeEntry(
const TQString& pKey,
double nValue,
1237 bool bPersistent =
true,
bool bGlobal =
false,
1238 char format =
'g',
int precision = 6,
1239 bool bNLS =
false );
1257 void writeEntry(
const char *pKey,
double nValue,
1258 bool bPersistent =
true,
bool bGlobal =
false,
1259 char format =
'g',
int precision = 6,
1260 bool bNLS =
false );
1276 void writeEntry(
const TQString& pKey,
bool bValue,
1277 bool bPersistent =
true,
bool bGlobal =
false,
1278 bool bNLS =
false );
1293 void writeEntry(
const char *pKey,
bool bValue,
1294 bool bPersistent =
true,
bool bGlobal =
false,
1295 bool bNLS =
false );
1311 void writeEntry(
const TQString& pKey,
const TQFont& rFont,
1312 bool bPersistent =
true,
bool bGlobal =
false,
1313 bool bNLS =
false );
1328 void writeEntry(
const char *pKey,
const TQFont& rFont,
1329 bool bPersistent =
true,
bool bGlobal =
false,
1330 bool bNLS =
false );
1349 void writeEntry(
const TQString& pKey,
const TQColor& rColor,
1350 bool bPersistent =
true,
bool bGlobal =
false,
1351 bool bNLS =
false );
1369 void writeEntry(
const char *pKey,
const TQColor& rColor,
1370 bool bPersistent =
true,
bool bGlobal =
false,
1371 bool bNLS =
false );
1390 void writeEntry(
const TQString& pKey,
const TQDateTime& rDateTime,
1391 bool bPersistent =
true,
bool bGlobal =
false,
1392 bool bNLS =
false );
1410 void writeEntry(
const char *pKey,
const TQDateTime& rDateTime,
1411 bool bPersistent =
true,
bool bGlobal =
false,
1412 bool bNLS =
false );
1432 void writeEntry(
const TQString& pKey,
const TQRect& rValue,
1433 bool bPersistent =
true,
bool bGlobal =
false,
1434 bool bNLS =
false );
1452 void writeEntry(
const char *pKey,
const TQRect& rValue,
1453 bool bPersistent =
true,
bool bGlobal =
false,
1454 bool bNLS =
false );
1473 void writeEntry(
const TQString& pKey,
const TQPoint& rValue,
1474 bool bPersistent =
true,
bool bGlobal =
false,
1475 bool bNLS =
false );
1493 void writeEntry(
const char *pKey,
const TQPoint& rValue,
1494 bool bPersistent =
true,
bool bGlobal =
false,
1495 bool bNLS =
false );
1514 void writeEntry(
const TQString& pKey,
const TQSize& rValue,
1515 bool bPersistent =
true,
bool bGlobal =
false,
1516 bool bNLS =
false );
1534 void writeEntry(
const char *pKey,
const TQSize& rValue,
1535 bool bPersistent =
true,
bool bGlobal =
false,
1536 bool bNLS =
false );
1555 void writePathEntry(
const TQString& pKey,
const TQString & path,
1556 bool bPersistent =
true,
bool bGlobal =
false,
1557 bool bNLS =
false );
1575 void writePathEntry(
const char *pKey,
const TQString & path,
1576 bool bPersistent =
true,
bool bGlobal =
false,
1577 bool bNLS =
false );
1598 void writePathEntry(
const char *pKey,
const TQString & path,
1599 bool bPersistent,
bool bGlobal,
1600 bool bNLS,
bool expand );
1625 void writePathEntry(
const TQString& pKey,
const TQStringList &rValue,
1626 char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
1650 void writePathEntry(
const char *pKey,
const TQStringList &rValue,
1651 char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
1662 void deleteEntry(
const TQString& pKey,
1663 bool bNLS =
false,
bool bGlobal =
false);
1672 void deleteEntry(
const char *pKey,
1673 bool bNLS =
false,
bool bGlobal =
false);
1692 bool deleteGroup(
const TQString& group,
bool bDeep =
true,
bool bGlobal =
false );
1725 virtual void rollback(
bool bDeep =
true );
1740 virtual void sync();
1773 bool hasKey(
const TQString& key )
const;
1785 virtual TQMap<TQString, TQString>
entryMap(
const TQString &group)
const = 0;
1805 bool isImmutable()
const;
1813 bool groupIsImmutable(
const TQString &group)
const;
1821 bool entryIsImmutable(
const TQString &key)
const;
1843 ConfigState getConfigState()
const;
1851 bool checkConfigFilesWritable(
bool warnUser);
1859 void setReadDefaults(
bool b);
1866 bool readDefaults()
const;
1879 void revertToDefault(
const TQString &key);
1907 bool hasDefault(
const TQString &key)
const;
1922 virtual void setDirty(
bool _bDirty =
true) { bDirty = _bDirty; }
1929 virtual void parseConfigFiles();
1994 virtual bool internalHasGroup(
const TQCString &group)
const = 0;
2004 void setGroup(
const TQCString &pGroup );
2005 void setGroup(
const char *pGroup );
2006 bool hasGroup(
const TQCString &_pGroup)
const;
2007 bool hasGroup(
const char *_pGroup)
const;
2008 bool hasKey(
const char *pKey )
const;
2011 TQCString readEntryUtf8(
const char *pKey)
const;
2012 bool hasTranslatedKey(
const char *pKey )
const;
2027 bool bLocaleInitialized;
2029 mutable bool bExpand;
2032 virtual void virtual_hook(
int id,
void* data );
2034 class TDEConfigBasePrivate;
2035 TDEConfigBasePrivate *d;
2037 void writeEntry(
const char *pKey,
const TQString &rValue,
2038 bool bPersistent,
bool bGlobal,
bool bNLS,
bool bExpand );
2039 void writeEntry(
const char *pKey,
const TQStringList &rValue,
2040 char sep,
bool bPersistent,
bool bGlobal,
bool bNLS,
bool bExpand );
2044class TDEConfigGroupSaverPrivate;
2096 : _config(config), _oldgroup(config->group())
2097 { _config->setGroup( group ); }
2100 : _config(config), _oldgroup(config->group())
2101 { _config->setGroup( group ); }
2104 : _config(config), _oldgroup(config->group())
2105 { _config->setGroup( group ); }
2118 TDEConfigGroupSaverPrivate *d;
2121class TDEConfigGroupPrivate;
2156 void deleteGroup(
bool bGlobal =
false);
2164 bool groupIsImmutable()
const;
2167 virtual void setDirty(
bool _bDirty);
2168 virtual void putData(
const KEntryKey &_key,
const KEntry &_data,
bool _checkGroup =
true);
2170 virtual void sync();
2175 void setDesktopGroup() { }
2178 void setReadOnly(
bool) { }
2182 virtual TQStringList groupList()
const {
return TQStringList(); }
2183 virtual void rollback(
bool) { }
2184 virtual void reparseConfiguration() { }
2185 virtual TQMap<TQString, TQString> entryMap(
const TQString &)
const
2186 {
return TQMap<TQString,TQString>(); }
2187 virtual KEntryMap internalEntryMap(
const TQString&)
const
2188 {
return KEntryMap(); }
2189 virtual KEntryMap internalEntryMap()
const
2190 {
return KEntryMap(); }
2191 virtual bool internalHasGroup(
const TQCString &)
const
2194 void getConfigState() { }
2198 virtual void virtual_hook(
int id,
void* data );
2200 TDEConfigGroupPrivate* d;
Abstract base class for KDE configuration file loading/saving.
KDE Configuration Management abstract base class.
virtual KEntry lookupData(const KEntryKey &_key) const =0
Looks up an entry in the config object's internal structure.
virtual KEntryMap internalEntryMap() const =0
Returns a map (tree) of the entries in the tree.
void writeEntry(const char *pKey, const char *pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Write a (key/value) pair.
virtual TQStringList groupList() const =0
Returns a list of groups that are known about.
TDEConfigBackEnd * backEnd
A back end for loading/saving to disk in a particular format.
virtual void reparseConfiguration()=0
Reparses all configuration files.
void setDollarExpansion(bool _bExpand=true)
Turns on or off "dollar expansion" (see TDEConfigBase introduction) when reading config entries.
bool isReadOnly() const
Returns the read-only status of the config object.
virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup=true)=0
Inserts a (key/value) pair into the internal storage mechanism of the configuration object.
TQCString aLocaleString
The locale to retrieve keys under if possible, i.e en_US or fr.
bool isDirty() const
Checks whether the config file has any dirty (modified) entries.
void writeEntry(const TQString &pKey, const char *pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Write a (key/value) pair.
ConfigState
Possible return values for getConfigState().
bool isDollarExpansion() const
Returns whether dollar expansion is on or off.
virtual void setDirty(bool _bDirty=true)
Sets the global dirty flag of the config object.
virtual void setReadOnly(bool _ro)
Sets the config object's read-only status.
virtual KEntryMap internalEntryMap(const TQString &pGroup) const =0
Returns a map (tree) of the entries in the specified group.
bool bDirty
Indicates whether there are any dirty entries in the config object that need to be written back to di...
TQCString mGroup
The currently selected group.
virtual TQMap< TQString, TQString > entryMap(const TQString &group) const =0
Returns a map (tree) of entries for all entries in a particular group.
Helper class to facilitate working with TDEConfig / TDESimpleConfig groups.
TDEConfigGroupSaver(TDEConfigBase *config, TQString group)
Constructor.
A TDEConfigBase derived class for one specific group in a TDEConfig object.
Class for KDE INI-style configuration file loading/saving.
key structure holding both the actual key and the the group to which it belongs.
map/dict/list config node entry.