Qtopia library API Documentation

Config Class Reference

The Config class provides for saving application cofniguration state. More...

#include <config.h>

Collaboration diagram for Config:

Collaboration graph
[legend]
List of all members.

Public Types

typedef QMap< QString, QStringConfigGroup
enum  Domain { File, User }

Public Member Functions

 Config (const QString &name, Domain domain=User)
 ~Config ()
bool operator== (const Config &other) const
bool operator!= (const Config &other) const
bool isValid () const
bool hasKey (const QString &key) const
bool hasGroup (const QString &gname) const
QStringList groupList () const
void setGroup (const QString &gname)
void writeEntry (const QString &key, const char *value)
void writeEntry (const QString &key, const QString &value)
void writeEntryCrypt (const QString &key, const QString &value)
void writeEntry (const QString &key, int num)
void writeEntry (const QString &key, const QStringList &lst, const QChar &sep)
void removeEntry (const QString &key)
QString readEntry (const QString &key, const QString &deflt=QString::null) const
QString readEntryCrypt (const QString &key, const QString &deflt=QString::null) const
QString readEntryDirect (const QString &key, const QString &deflt=QString::null) const
int readNumEntry (const QString &key, int deflt=-1) const
bool readBoolEntry (const QString &key, bool deflt=FALSE) const
QStringList readListEntry (const QString &key, const QChar &sep) const
QString readEntry (const QString &key, const QString &deflt)
QString readEntryCrypt (const QString &key, const QString &deflt)
QString readEntryDirect (const QString &key, const QString &deflt)
int readNumEntry (const QString &key, int deflt)
bool readBoolEntry (const QString &key, bool deflt)
QStringList readListEntry (const QString &key, const QChar &sep)
void clearGroup ()
void write (const QString &fn=QString::null)

Protected Member Functions

void read ()
bool parse (const QString &line)

Static Protected Member Functions

QString configFilename (const QString &name, Domain)

Protected Attributes

QMap< QString, ConfigGroupgroups
QMap< QString, ConfigGroup
>::Iterator 
git
QString filename
QString lang
QString glang
bool changed
ConfigPrivate * d

Detailed Description

The Config class provides for saving application cofniguration state.

You should keep a Config in existence only while you do not want others to be able to change the state. There is no locking currently, but there may be in the future.

Definition at line 30 of file config.h.


Member Enumeration Documentation

enum Config::Domain
 

File User

See Config for details.

Definition at line 35 of file config.h.


Constructor & Destructor Documentation

Config::Config const QString name,
Domain  domain = User
 

Constructs a config that will load or create a configuration with the given name in the given domain.

You must call setGroup() before doing much else with the Config.

In the default Domain, User, the configuration is user-specific. name should not contain "/" in this case, and in general should be the name of the C++ class that is primarily responsible for maintaining the configuration.

In the File Domain, name is an absolute filename.

Definition at line 95 of file config.cpp.

References QMap< QString, ConfigGroup >::end().

Config::~Config  ) 
 

Writes any changes to disk and destroys the in-memory object.

Definition at line 120 of file config.cpp.


Member Function Documentation

bool Config::operator== const Config other  )  const [inline]
 

Tests for equality with other. Config objects are equal if they refer to the same filename.

Definition at line 39 of file config.h.

References filename.

bool Config::operator!= const Config other  )  const [inline]
 

Tests for inequality with other. Config objects are equal if they refer to the same filename.

Definition at line 40 of file config.h.

References filename.

bool Config::isValid  )  const
 

Returns whether the Config is in a valid state.

Definition at line 501 of file config.cpp.

References QMap< QString, ConfigGroup >::end().

Referenced by AppLnk::AppLnk().

bool Config::hasKey const QString key  )  const
 

Returns whether the current group has an entry called key.

Definition at line 129 of file config.cpp.

References QMap< QString, ConfigGroup >::end().

void Config::setGroup const QString gname  ) 
 

Sets the current group for subsequent reading and writing of entries to gname. Grouping allows the application to partition the namespace.

This function must be called prior to any reading or writing of entries.

The gname must not be empty.

Definition at line 146 of file config.cpp.

References QMap< QString, ConfigGroup >::end(), QMap< QString, ConfigGroup >::find(), and QMap< QString, ConfigGroup >::insert().

Referenced by AppLnk::AppLnk().

void Config::writeEntry const QString key,
const char *  value
 

Writes a (key, value) entry to the current group.

See also:
readEntry()

Definition at line 162 of file config.cpp.

Referenced by AppLnk::setProperty(), and writeEntry().

void Config::writeEntry const QString key,
const QString value
 

Writes a (key, value) entry to the current group.

See also:
readEntry()

Definition at line 172 of file config.cpp.

References QMap< QString, ConfigGroup >::end().

void Config::writeEntryCrypt const QString key,
const QString value
 

Writes an encrypted (key, value) entry to the current group.

Note that the degree of protection offered by the encryption is only sufficient to avoid the most casual observation of the configuration files.

See also:
readEntry()

Definition at line 232 of file config.cpp.

References QMap< QString, ConfigGroup >::end().

void Config::writeEntry const QString key,
int  num
 

Writes a (key, num) entry to the current group.

See also:
readNumEntry()

Definition at line 250 of file config.cpp.

References writeEntry().

void Config::writeEntry const QString key,
const QStringList lst,
const QChar sep
 

Writes a (key, lst) entry to the current group. The list is separated by sep, so the strings must not contain that character.

See also:
readListEntry()

Definition at line 278 of file config.cpp.

References QValueList::begin(), QValueList::end(), and writeEntry().

void Config::removeEntry const QString key  ) 
 

Removes the key entry from the current group. Does nothing if there is no such entry.

Definition at line 292 of file config.cpp.

References QMap< QString, ConfigGroup >::end().

QString Config::readEntry const QString key,
const QString deflt = QString::null
const [inline]
 

Reads a string entry stored with key, defaulting to deflt if there is no entry.

Definition at line 96 of file config.h.

Referenced by AppLnk::AppLnk(), and AppLnk::property().

QString Config::readEntryCrypt const QString key,
const QString deflt = QString::null
const [inline]
 

Reads an encrypted string entry stored with key, defaulting to deflt if there is no entry.

Definition at line 98 of file config.h.

int Config::readNumEntry const QString key,
int  deflt = -1
const [inline]
 

Reads a numeric entry stored with key, defaulting to deflt if there is no entry.

Definition at line 102 of file config.h.

bool Config::readBoolEntry const QString key,
bool  deflt = FALSE
const [inline]
 

Reads a bool entry stored with key, defaulting to deflt if there is no entry.

Definition at line 104 of file config.h.

QStringList Config::readListEntry const QString key,
const QChar sep
const [inline]
 

Reads a string list entry stored with key, and with sep as the separator.

Definition at line 106 of file config.h.

Referenced by AppLnk::AppLnk().

void Config::clearGroup  ) 
 

Removes all entries from the current group.

Definition at line 438 of file config.cpp.

References QMap< QString, ConfigGroup >::end().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for OPIE Version 1.5.5.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:24:15 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001