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

Config Class Reference

#include <Config.h>

List of all members.


Detailed Description

The Config class stores information about the application that is user editable or about to change.

This configuration is structured into sections, containing sections and/or parameters. The sections may be nested as deep as required.

Author:
Thomas Jacob

Definition at line 69 of file Config.h.

Public Member Functions

void Clear ()
 Clears the whole configuration object, removing all sections and parameters.

 Config ()
 Creates a new configuration.

bool ExportIni (const char *fileName)
 Exports the configuration into an INI file.

bool ExportIni ()
 Exports the configuration into an INI file.

ConfigSectionGetContent ()
 Returns the main configuration section, the root entry.

bool ImportIni (const char *fileName)
 Imports an INI file as configuration.

bool ImportIni ()
 Imports an INI file as configuration.

bool Parse (char *text)
 Deserializes (reads) the configuration from a string.

bool Read (const char *fileName)
 Reads the configuration from a config file.

bool Read ()
 Reads the configuration from a config file.

bool Write (class Config::Writer *Writer, bool indent=true)
 Writes the configuration into a given writer, for example a string writer.

bool Write (const char *fileName, bool withBacking=false, bool indent=true)
 Writes the configuration into a config file.

bool Write (bool withBacking=false, bool indent=true)
 Writes the configuration into a config file.

 ~Config ()
 Destroys the configuration.


Static Private Member Functions

bool WriteCorrectedForCfgFile (class Config::Writer *Writer, const char *str)
 Writes a given string to a file, after having it modified so that all illegal characters are escaped with a back slash.


Private Attributes

friend ConfigParameter
friend ConfigSection
ConfigSectionContent
 The main section, the root entry for all further sections and parameters.


Constructor & Destructor Documentation

Config  ) 
 

Creates a new configuration.

~Config  ) 
 

Destroys the configuration.


Member Function Documentation

void Clear  ) 
 

Clears the whole configuration object, removing all sections and parameters.

bool ExportIni const char *  fileName  ) 
 

Exports the configuration into an INI file.

Parameters:
fileName The name of the file to write to.
Warning:
Since INI files do not support nested sections, any sections deeper than 1 will be lost.
Returns:
If the configuration was successfully written.

bool ExportIni  ) 
 

Exports the configuration into an INI file.

The method uses the application's name with the suffix INI. Use the parametered overload to choose the file name.

Warning:
Since INI files do not support nested sections, any sections deeper than 1 will be lost.
Returns:
If the configuration was successfully written.

ConfigSection* GetContent  )  [inline]
 

Returns the main configuration section, the root entry.

Returns:
The main section.

bool ImportIni const char *  fileName  ) 
 

Imports an INI file as configuration.

Any configuration in the object is deleted in prior.

Parameters:
fileName The name of the file to read from.
Returns:
If the configuration was successfully read. This value is false, especially when the file does not exist or when it has syntax errors. In this case, the configuration remains empty.

bool ImportIni  ) 
 

Imports an INI file as configuration.

Any configuration in the object is deleted in prior. The method uses the application's name with the suffix INI. Use the parametered overload to choose the file name.

Returns:
If the configuration was successfully read. This value is false, especially when the file does not exist or when it has syntax errors. In this case, the configuration remains empty.

bool Parse char *  text  ) 
 

Deserializes (reads) the configuration from a string.

Parameters:
text The string to read the config from.
Returns:
If the configuration was successfully read. This value is false, if the string is syntactically invalid. In this case, the configuration remains empty.

bool Read const char *  fileName  ) 
 

Reads the configuration from a config file.

Any configuration in the object is deleted in prior.

Parameters:
fileName The name of the file to read from.
Returns:
If the configuration was successfully read. This value is false, especially when the file does not exist or when it has syntax errors. In this case, the configuration remains empty.

bool Read  ) 
 

Reads the configuration from a config file.

Any configuration in the object is deleted in prior. The method uses the application's name with the suffix CFG. Use the parametered overload to choose the file name.

Returns:
If the configuration was successfully read. This value is false, especially when the file does not exist or when it has syntax errors. In this case, the configuration remains empty.

bool Write class Config::Writer Writer,
bool  indent = true
 

Writes the configuration into a given writer, for example a string writer.

Parameters:
Writer The writer to write to.
indent Whether to indent values according to their structural depth. Default is false.
Returns:
Whether the configuration was successfully written.

bool Write const char *  fileName,
bool  withBacking = false,
bool  indent = true
 

Writes the configuration into a config file.

Parameters:
fileName The name of the file to write to.
withBacking Whether the configuration shall be written to a backing file first, and after writing has been completed, it shall be moved to its final destination. Default is false.
indent Whether to indent values according to their structural depth. Default is false.
Returns:
If the configuration was successfully written.

bool Write bool  withBacking = false,
bool  indent = true
 

Writes the configuration into a config file.

The method uses the application's name with the suffix CFG. Use the parametered overload to choose the file name.

Parameters:
withBacking Whether the configuration shall be written to a backing file first, and after writing has been completed, it shall be moved to its final destination. Default is false.
indent Whether to indent values according to their structural depth. Default is false.
Returns:
If the configuration was successfully written.

bool WriteCorrectedForCfgFile class Config::Writer Writer,
const char *  str
[static, private]
 

Writes a given string to a file, after having it modified so that all illegal characters are escaped with a back slash.

Parameters:
Writer The writer to write to.
str The string to be written.
Returns:
Whether the writing was successful.


Member Data Documentation

friend ConfigParameter [private]
 

Definition at line 73 of file Config.h.

friend ConfigSection [private]
 

Definition at line 72 of file Config.h.

ConfigSection* Content [private]
 

The main section, the root entry for all further sections and parameters.

Definition at line 233 of file Config.h.


The documentation for this class was generated from the following file:
Generated on Tue Oct 3 00:23:39 2006 for ToolBox by doxygen 1.3.6