Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SWConfig Class Reference

The class to read and save settings using a file on disk. More...

#include <swconfig.h>

List of all members.

Public Methods

 SWConfig (const char *ifilename)
 Constructor of SWConfig. More...

virtual ~SWConfig ()
virtual void Load ()
 Load from disk Load the contzent from disk.

virtual void Save ()
 Save to disk Save the content of this config object to disk.

virtual SWConfig & operator+= (SWConfig &addFrom)
 Merges the values of addFrom. More...

virtual ConfigEntMap & operator[] (const char *section)
 Get a section This is an easy way to get and store config values. More...


Public Attributes

string filename
 The filename used by this SWConfig object.

SectionMap Sections
 Map of available sections The map of available sections.


Private Methods

char getline (FILE *fp, string &line)


Detailed Description

The class to read and save settings using a file on disk.

Definition at line 44 of file swconfig.h.


Constructor & Destructor Documentation

SWConfig::SWConfig const char *    ifilename
 

Constructor of SWConfig.

Parameters:
ifilename  The file, which should be used for this config.

Definition at line 27 of file swconfig.cpp.

References filename, and Load.

00027                                          {
00028         filename = ifilename;
00029         Load();
00030 }


Member Function Documentation

SWConfig & SWConfig::operator+= SWConfig &    addFrom [virtual]
 

Merges the values of addFrom.

Parameters:
The  config which values should be merged to this config object. Already existing values will be overwritten.

Definition at line 134 of file swconfig.cpp.

References Sections.

00135 {
00136 
00137         SectionMap::iterator section;
00138         ConfigEntMap::iterator entry;
00139 
00140         for (section = addFrom.Sections.begin(); section != addFrom.Sections.end(); section++) {
00141                 for (entry = (*section).second.begin(); entry != (*section).second.end(); entry++) {
00142                         Sections[(*section).first].insert(ConfigEntMap::value_type((*entry).first, (*entry).second));
00143                 }
00144         }
00145         return *this;
00146 }

ConfigEntMap & SWConfig::operator[] const char *    section [virtual]
 

Get a section This is an easy way to get and store config values.

The following will work:

 SWConfig config("/home/user/.setttings");
 config["Colors"]["Background"] = "red";

Definition at line 148 of file swconfig.cpp.

References Sections.

00148                                                          {
00149     return Sections[section];
00150 }


The documentation for this class was generated from the following files:
Generated on Wed Apr 3 22:34:17 2002 for The Sword Project by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002