KConfigBase Class Reference

[kdecore Index] [kdecore Hierarchy] [Headers]


KDE Configuration Management abstract base class More...

#include <kconfigbase.h>

Inherits: QObject (qt)

Public Members

Protected Members


Detailed Description

Abstract base class for KDE configuration entries

This class forms the base for all KDE configuration. It is an abstract base class, meaning that you cannot directly instantiate objects of this class. Either use KConfig (for usual KDE configuration) or KSimpleConfig (for special needs like ksamba). one application, independent of the configuration files they came from.

All configuration entries are of the form "key=value" and belong to a certain group. A group can be specified in a configuration file with "[GroupName]". All configuration entries from the beginning of a configuration file to the first group declaration belong to a special group called the default group.

If there is a $ character in a entry, KConfig tries to expand environment variable and uses its value instead of its name. You can avoid this feature by having two consecutive $ characters in your config file which get expanded to one.

Lines starting with a hash mark(#) are comment lines.

See Also: KApplication


KConfigBase() [public]

Construct a KConfigBase object.

~KConfigBase() [public virtual]

Destructor.

Writes back any dirty configuration entries.

void setGroup( const char* pGroup ) [public]

Specify the group in which keys will be searched.

Switch back to the default group by passing an empty string.

Parameters:
pGroup The name of the new group.

const char* group() const [public]

Retrieve the group where keys are currently searched in.

Returns:
The current group

const char* getGroup() const [public]

Retrieve the group where keys are currently searched in. Note: this method is deprecated; use KConfigBase::group() instead.

Returns:
The current group

const QString readEntry( const char* pKey, const char* pDefault = 0L ) const [public]

Read the value of an entry specified by rKey in the current group

Parameters:
pKey The key to search for.
pDefault A default value returned if the key was not found.
Returns:
The value for this key or an empty string if no value was found.

int readListEntry( const char* pKey, QStrList &list, char sep = ',' ) const [public]

Read a list of strings.

Parameters:
sep The list separator (default ",")
pKey The key to search for
list In this object, the read list will be returned.
Returns:
The number of entries in the list.

int readNumEntry( const char* pKey, int nDefault = 0 ) const [public]

Read a numerical value.

Read the value of an entry specified by rKey in the current group and interpret it numerically.

Parameters:
pKey The key to search for.
nDefault A default value returned if the key was not found.
Returns:
The value for this key or 0 if no value was found.

unsigned int readUnsignedNumEntry( const char* pKey, unsigned int nDefault = 0 ) const [public]

Read a numerical value.

Read the value of an entry specified by rKey in the current group and interpret it numerically.

Parameters:
pKey The key to search for.
nDefault A default value returned if the key was not found.
Returns:
The value for this key or 0 if no value was found.

long readLongNumEntry( const char* pKey, long nDefault = 0 ) const [public]

Read a numerical value.

Read the value of an entry specified by rKey in the current group and interpret it numerically.

Parameters:
pKey The key to search for.
nDefault A default value returned if the key was not found.
Returns:
The value for this key or 0 if no value was found.

unsigned long readUnsignedLongNumEntry( const char* pKey, unsigned long nDefault = 0 ) const [public]

Read a numerical value.

Read the value of an entry specified by rKey in the current group and interpret it numerically.

Parameters:
pKey The key to search for.
nDefault A default value returned if the key was not found.
Returns:
The value for this key or 0 if no value was found.

double readDoubleNumEntry( const char* pKey, double nDefault = 0.0 ) const [public]

Read a numerical value.

Read the value of an entry specified by rKey in the current group and interpret it numerically.

Parameters:
pKey The key to search for.
nDefault A default value returned if the key was not found.
Returns:
The value for this key or 0 if no value was found.

QFont readFontEntry( const char* pKey, const QFont* pDefault = 0L ) const [public]

Read a QFont.

Read the value of an entry specified by rKey in the current group and interpret it as a font object.

Parameters:
pKey The key to search for.
pDefault A default value returned if the key was not found.
Returns:
The value for this key or a default font if no value was found.

bool readBoolEntry( const char* pKey, const bool bDefault = false ) const [public]

Read a boolean entry.

Read the value of an entry specified by pKey in the current group and interpret it as a boolean value. Currently "on" and "true" are accepted as true, everything else if false.

Parameters:
pKey The key to search for
bDefault A default value returned if the key was not found.
Returns:
The value for this key or a default value if no value was found.

QRect readRectEntry( const char* pKey, const QRect* pDefault = 0L ) const [public]

Read a rect entry.

Read the value of an entry specified by pKey in the current group and interpret it as a QRect object.

Parameters:
pKey The key to search for
pDefault A default value returned if the key was not found.
Returns:
The value for this key or a default rectangle if no value was found.

QPoint readPointEntry( const char* pKey, const QPoint* pDefault = 0L ) const [public]

Read a point entry.

Read the value of an entry specified by pKey in the current group and interpret it as a QPoint object.

Parameters:
pKey The key to search for
pDefault A default value returned if the key was not found.
Returns:
The value for this key or a default point if no value was found.

QSize readSizeEntry( const char* pKey, const QSize* pDefault = 0L ) const [public]

Read a size entry.

Read the value of an entry specified by pKey in the current group and interpret it as a QSize object.

Parameters:
pKey The key to search for
pDefault A default value returned if the key was not found.
Returns:
The value for this key or a default point if no value was found.

QColor readColorEntry( const char* pKey, const QColor* pDefault = 0L ) const [public]

Read a QColor.

Read the value of an entry specified by rKey in the current group and interpret it as a color.

Parameters:
pKey The key to search for.
pDefault A default value returned if the key was not found.
Returns:
The value for this key or a default color if no value was found.

const char* writeEntry( const char* pKey, const char* pValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false ) [public]

Write the key/value pair. This is stored to the most specific config file when destroying the config object or when calling sync().

Parameters:
pKey The key to write.
bGlobal If bGlobal is true, the pair is not saved to the application specific config file, but to the global ~/.kderc
bPersistent If bPersistent is false, the entry's dirty flag will not be set and thus the entry will not be written to disk at deletion time.
pValue The value to write.
bNLS If bNLS is true, the locale tag is added to the key when writing it back.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

void writeEntry( const char* pKey, QStrList &list, char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ) [public]

writeEntry() overriden to accept a list of strings.

Note: Unlike the other writeEntry() functions, the old value is _not_ returned here!

Parameters:
sep The list separator
pKey The key to write
bGlobal If bGlobal is true, the pair is not saved to the application specific config file, but to the global ~/.kderc
bPersistent If bPersistent is false, the entry's dirty flag will not be set and thus the entry will not be written to disk at deletion time.
list The list to write
bNLS If bNLS is true, the locale tag is added to the key when writing it back.
See Also:
writeEntry

const char* writeEntry( const char* pKey, int nValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false ) [public]

Write the key value pair.Same as above, but write a numerical value.

Parameters:
pKey The key to write.
bGlobal If bGlobal is true, the pair is not saved to the application specific config file, but to the global ~/.kderc
bPersistent If bPersistent is false, the entry's dirty flag will not be set and thus the entry will not be written to disk at deletion time.
nValue The value to write.
bNLS If bNLS is true, the locale tag is added to the key when writing it back.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

const char* writeEntry( const char* pKey, unsigned int nValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false ) [public]

Write the key value pair.Same as above, but write an unsigned numerical value.

Parameters:
pKey The key to write.
bGlobal If bGlobal is true, the pair is not saved to the application specific config file, but to the global ~/.kderc
bPersistent If bPersistent is false, the entry's dirty flag will not be set and thus the entry will not be written to disk at deletion time.
nValue The value to write.
bNLS If bNLS is true, the locale tag is added to the key when writing it back.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

const char* writeEntry( const char* pKey, long nValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false ) [public]

Write the key value pair.Same as above, but write a long numerical value.

Parameters:
pKey The key to write.
bGlobal If bGlobal is true, the pair is not saved to the application specific config file, but to the global ~/.kderc
bPersistent If bPersistent is false, the entry's dirty flag will not be set and thus the entry will not be written to disk at deletion time.
nValue The value to write.
bNLS If bNLS is true, the locale tag is added to the key when writing it back.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

const char* writeEntry( const char* pKey, unsigned long nValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false ) [public]

Write the key value pair.Same as above, but write an unsigned long numerical value.

Parameters:
pKey The key to write.
bGlobal If bGlobal is true, the pair is not saved to the application specific config file, but to the global ~/.kderc
bPersistent If bPersistent is false, the entry's dirty flag will not be set and thus the entry will not be written to disk at deletion time.
nValue The value to write.
bNLS If bNLS is true, the locale tag is added to the key when writing it back.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

const char* writeEntry( const char* pKey, double nValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false ) [public]

Write the key value pair.Same as above, but write a floating-point value.

Parameters:
pKey The key to write.
bGlobal If bGlobal is true, the pair is not saved to the application specific config file, but to the global ~/.kderc
bPersistent If bPersistent is false, the entry's dirty flag will not be set and thus the entry will not be written to disk at deletion time.
nValue The value to write.
bNLS If bNLS is true, the locale tag is added to the key when writing it back.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

const char* writeEntry( const char* pKey, bool bValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false ) [public]

Write the key value pair.Same as above, but write a boolean value.

Parameters:
pKey The key to write.
bGlobal If bGlobal is true, the pair is not saved to the application specific config file, but to the global ~/.kderc
bPersistent If bPersistent is false, the entry's dirty flag will not be set and thus the entry will not be written to disk at deletion time.
bNLS If bNLS is true, the locale tag is added to the key when writing it back.
bValue The value to write.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

const char* writeEntry( const char* pKey, const QFont& rFont, bool bPersistent = true, bool bGlobal = false, bool bNLS = false ) [public]

Write the key value pair.Same as above, but write a font

Parameters:
rFont The font value to write.
pKey The key to write.
bGlobal If bGlobal is true, the pair is not saved to the application specific config file, but to the global ~/.kderc
bPersistent If bPersistent is false, the entry's dirty flag will not be set and thus the entry will not be written to disk at deletion time.
bNLS If bNLS is true, the locale tag is added to the key when writing it back.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

void writeEntry( const char* pKey, const QColor& rColor, bool bPersistent = true, bool bGlobal = false, bool bNLS = false ) [public]

Write the key value pair.Same as above, but write a color

Parameters:
pKey The key to write.
bGlobal If bGlobal is true, the pair is not saved to the application specific config file, but to the global ~/.kderc
bPersistent If bPersistent is false, the entry's dirty flag will not be set and thus the entry will not be written to disk at deletion time.
bNLS If bNLS is true, the locale tag is added to the key when writing it back.
rValue The color value to write.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

void writeEntry( const char* pKey, const QRect& rColor, bool bPersistent = true, bool bGlobal = false, bool bNLS = false ) [public]

Write the key value pair.Same as above, but write a rectangle

Parameters:
pKey The key to write.
bGlobal If bGlobal is true, the pair is not saved to the application specific config file, but to the global ~/.kderc
bPersistent If bPersistent is false, the entry's dirty flag will not be set and thus the entry will not be written to disk at deletion time.
bNLS If bNLS is true, the locale tag is added to the key when writing it back.
rValue The rectangle value to write.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

void writeEntry( const char* pKey, const QPoint& rColor, bool bPersistent = true, bool bGlobal = false, bool bNLS = false ) [public]

Write the key value pair.Same as above, but write a point

Parameters:
pKey The key to write.
bGlobal If bGlobal is true, the pair is not saved to the application specific config file, but to the global ~/.kderc
bPersistent If bPersistent is false, the entry's dirty flag will not be set and thus the entry will not be written to disk at deletion time.
bNLS If bNLS is true, the locale tag is added to the key when writing it back.
rValue The point value to write.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

void writeEntry( const char* pKey, const QSize& rColor, bool bPersistent = true, bool bGlobal = false, bool bNLS = false ) [public]

Write the key value pair.Same as above, but write a size

Parameters:
pKey The key to write.
bGlobal If bGlobal is true, the pair is not saved to the application specific config file, but to the global ~/.kderc
bPersistent If bPersistent is false, the entry's dirty flag will not be set and thus the entry will not be written to disk at deletion time.
bNLS If bNLS is true, the locale tag is added to the key when writing it back.
rValue The size value to write.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

void setDollarExpansion( bool bExpand = true ) [public]

Turns on or off "dollar expansion" when reading config entries.

Parameters:
bExpand if true, dollar expansion is turned on.

bool isDollarExpansion() const [public]

Returns whether dollar expansion is on or off.

Returns:
true if dollar expansion is on.

void rollback( bool bDeep = true ) [public virtual]

Don't write dirty entries at destruction time. If bDeep isfalse, only the global dirty flag of the KConfig object gets cleared. If you then call writeEntry again, the global dirty flag is set again and all dirty entries will be written.

Parameters:
bDeep if true, the dirty flags of all entries are cleared, as well as the global dirty flag.

void sync() [public virtual]

Flush the entry cache. Write back dirty configuration entries tothe most specific file. This is called automatically from the destructor. This method must be implemented by the derived classes.

bool hasKey( const char* pKey ) const [public]

Check if the key has an entry in the specified groupUse this to determine if a key is not specified for the current group (HasKey returns false) or is specified but has no value ("key =EOL"; Has Key returns true, ReadEntry returns an empty string)

Parameters:
pKey The key to search for.
Returns:
if true, the key is available

KGroupIterator* groupIterator(void) [public]

Returns an iterator on the list of groups

Returns:
The group iterator. The caller is reponsable for The group iterator. The caller is reponsable for

KEntryIterator* entryIterator( const char* pGroup ) [public]

Returns an iterator on the entries in the current group

Parameters:
pGroup the group to provide an iterator for
Returns:
The iterator for the group or 0, if the group does not The iterator for the group or 0, if the group does not

void reparseConfiguration() [public virtual]

Reparses all configuration files. This is useful for programmswhich use standalone graphical configuration tools.

KConfigBaseData* data() const [protected]

Access to the configuration data.

Returns:
a pointer to the configuration base data

void setLocale() [protected]

Read the locale and put in the configuration data struct. Note: This should be done in the constructor, but this is not possible due to some mutual dependencies in KApplication::init()

void parseConfigFiles() [protected virtual]

Parse all configuration files for a configuration object. This method must be reimplemented by the derived classes. It should go through the list of appropriate files for a configuration object, open the files and call parseOneConfigFile() for each one of them.

void parseOneConfigFile( QFile& rFile, KGroupDict* pGroup = 0L, bool bGlobal = false ) [protected virtual]

Parse one configuration file. This method contains the actual configuration file parser. It can overridden by derived classes for specific parsing needs. For normal use, this should not be necessary.

Parameters:
rFile The configuration file to parse
bGlobal
pGroup

bool writeConfigFile( QFile& rFile, bool bGlobal = false ) [protected virtual]

Write configuration file back. This method must be reimplemented by derived classes. It should dump the data of the configuration object to the appropriate files.

Parameters:
rFile The file to write
bGlobal Should the data be saved to a global file
Returns:
Whether some entries are left to be written to other files.

  • Author: Kalle Dalheimer (kalle@kde.org)
  • Version: $Id: KConfigBase.html.in,v 1.1.1.1 2000/02/09 22:24:52 tasin Exp $
  • Documentation generated by tasin@cd1 on Die Nov 30 17:31:35 CET 1999
Kdoc