Logo Search packages:      
Sourcecode: qtdmm version File versions  Download package

SimpleCfg Class Reference

#include <simplecfg.h>

List of all members.

Detailed Description

Encapsulation of an "Windows-ini-style" ASCII configuration file. You know these
    [operating system]
configuration files.

Usage is quite simple. Just create a SimpleCfg object and retrieve the needed values in your code. All retrieval member need a default value. This ensures that first usage of the configuration file (Means file does not exist on harddisk) will create a file with hopefully sane (you have to specify them :) default values. Next time you'll find a complete configuration file on disk.

You could use the above example as follows:

    SimpleCfg cfg( "filename" );
    cfg.load();   // The file is _not_ loaded in the constructor!
    cerr << "Windows " << cfg.getString( "operating system", "windows", "is good" ) 
         << endl;
    cerr << "Unix " << cfg.getString( "operating system", "unix", "is old crap" )
         << endl;
    cfg.save();   // If file did not exist it is created now.
If the file could be read you would see the following output:
    Windows sux
    Unix rocks
If the file could not be read:
    Windows is good
    Unix is old crap
So always ensure your configuration files can be read :)
You can not have two or more groups with the same name. Same applies to keys within a group.
SimpleCfg is licensed under GPL

Matthias Toussaint, © 2000 Matthias Toussaint

Definition at line 221 of file simplecfg.h.

Public Member Functions

void add (const QString &group)
QMap< QString, SimpleCfgGroup * >
begin ()
void clear ()
 Clear configuration.
bool contains (const QString &group, const QString &key)
bool contains (const QString &group)
QMap< QString, SimpleCfgGroup * >
end ()
QString filename () const
bool getBool (const QString &group, const QString &key, bool def)
double getDouble (const QString &group, const QString &key, double def)
int getInt (const QString &group, const QString &key, int def)
QRgb getRGB (const QString &group, const QString &key, QRgb def)
QString getString (const QString &group, const QString &key, const QString &def)
bool load ()
void remove (const QString &group)
void remove (const QString &group, const QString &key)
void removeEmpty ()
bool save ()
void setBool (const QString &group, const QString &key, bool val)
void setComment (const QString &comment)
void setDouble (const QString &group, const QString &key, double val)
void setFilename (const QString &fn)
void setInt (const QString &group, const QString &key, int val)
void setRGB (const QString &group, const QString &key, QRgb val)
void setString (const QString &group, const QString &key, const QString &val)
 SimpleCfg (const QString &)
 Construct empty configuration with filename.
virtual ~SimpleCfg ()

Protected Attributes

QString curGroup
QString fname
QString m_comment
QMap< QString, SimpleCfgGroup * > map

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index