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

ConfigSection Class Reference

#include <Config.h>

List of all members.


Detailed Description

A ConfigSection stores all sub-sections and parameters of a section in the configuation.

Author:
Thomas Jacob

Definition at line 404 of file Config.h.

Public Member Functions

bool ContainsParameter (const char *name)
 Returns whether a given parameter is existing.

bool ContainsSection (const char *name)
 Returns whether a given sub-section is existing.

void DeleteAllParameters ()
 Removes all parameters from the section.

void DeleteAllSections ()
 Removes all sub-sections from the section.

void DeleteParameter (const char *name)
 Removes a parameter from the section.

void DeleteSection (const char *name)
 Removes a sub-section from the section.

bool GetBoolValue (const char *name, bool defaultBoolValue)
 Returns a boolean value of a parameter.

bool GetBoolValue (const char *name)
 Returns a boolean value for a given name.

double GetDoubleValue (const char *name, double defaultDoubleValue)
 Returns a double float value of a parameter.

double GetDoubleValue (const char *name)
 Returns a double float value of a parameter.

int GetIntValue (const char *name, int defaultIntValue)
 Returns a integer value of a parameter.

int GetIntValue (const char *name)
 Returns a integer value of a parameter.

long GetLongValue (const char *name, long defaultLongValue)
 Returns a long integer value of a parameter.

long GetLongValue (const char *name)
 Returns a long integer value of a parameter.

const char * GetName ()
 Returns the name of the section.

ConfigParameterGetParameter (const char *name)
 Returns the ConfigParameter object for a given name or creates it, if it doesn't exist yet.

PointeredListGetParameterNames ()
 Returns a PointeredList of all parameter names in this section.

ConfigSectionGetSection (const char *name)
 Returns a sub-section of the section.

PointeredListGetSectionNames ()
 Returns a PointeredList of all section names in this section.

PointeredListGetSections ()
 Returns a PointeredList of all sections in this section.

const char * GetStringValue (const char *name, const char *defaultStringValue)
 Returns a string value of a parameter.

const char * GetStringValue (const char *name)
 Returns a string value of a parameter.

int GetType (const char *name)
 Returns the type of a given parameter.

bool HasParameter (const char *name)
 Returns whether the config section has a parameter with a given name.

bool HasSection (const char *name)
 Returns whether the config section has a sub section with a given name.

void SetBoolValue (const char *name, bool boolValue)
 Sets a boolean parameter for a given name.

void SetDoubleValue (const char *name, double doubleValue)
 Sets a double float parameter for a given name.

void SetIntValue (const char *name, int intValue)
 Sets a integer parameter for a given name.

void SetLongValue (const char *name, long longValue)
 Sets a long integer parameter for a given name.

void SetStringValue (const char *name, const char *stringValue)
 Sets a string parameter for a given name.


Private Member Functions

 ConfigSection (const char *name)
 Creates a new config section.

bool WriteTo (class Config::Writer *Writer, int depth, bool indent)
 Writes this section to a file.

 ~ConfigSection ()
 Destroys the config section.


Static Private Member Functions

bool WriteIndentation (class Config::Writer *Writer, int depth)
 Writes the indentation (tabs) according to the given depth into a file.


Private Attributes

friend Config
friend HashMap<ConfigSection>
char * Name
 The name of the section.

StringKeyHashMap< ConfigParameter > * Parameters
 The parameters in this section.

StringKeyHashMap< ConfigSection > * Sections
 The sub-sections in this section.


Constructor & Destructor Documentation

ConfigSection const char *  name  )  [private]
 

Creates a new config section.

Parameters:
name The name of the section.

~ConfigSection  )  [private]
 

Destroys the config section.


Member Function Documentation

bool ContainsParameter const char *  name  ) 
 

Returns whether a given parameter is existing.

Parameters:
name The name of the parameter.
Returns:
Whether the parameter is existing.

bool ContainsSection const char *  name  ) 
 

Returns whether a given sub-section is existing.

Parameters:
name The name of the section.
Returns:
Whether the section is existing.

void DeleteAllParameters  ) 
 

Removes all parameters from the section.

void DeleteAllSections  ) 
 

Removes all sub-sections from the section.

void DeleteParameter const char *  name  ) 
 

Removes a parameter from the section.

Parameters:
name The name of the parameter.

void DeleteSection const char *  name  ) 
 

Removes a sub-section from the section.

Parameters:
name The name of the sub-section.

bool GetBoolValue const char *  name,
bool  defaultBoolValue
 

Returns a boolean value of a parameter.

If the parameter is not of boolean type, it is converted in prior. The type is not changed when doing this.

Parameters:
name The name of the parameter.
defaultBoolValue The value to be used, if the parameter did not exist.
Returns:
The boolean value.

bool GetBoolValue const char *  name  )  [inline]
 

Returns a boolean value for a given name.

If the parameter is not of boolean type, it is converted in prior. The type is not changed when doing this.

Parameters:
name The name of the parameter.
Returns:
The boolean value.

double GetDoubleValue const char *  name,
double  defaultDoubleValue
 

Returns a double float value of a parameter.

If the parameter is not of double float type, it is converted in prior. The type is not changed when doing this.

Parameters:
name The name of the parameter.
defaultDoubleValue The value to be used, if the parameter did not exist.
Returns:
The double float value.

double GetDoubleValue const char *  name  )  [inline]
 

Returns a double float value of a parameter.

If the parameter is not of double float type, it is converted in prior. The type is not changed when doing this.

Parameters:
name The name of the parameter.
Returns:
The double float value.

int GetIntValue const char *  name,
int  defaultIntValue
 

Returns a integer value of a parameter.

If the parameter is not of integer type, it is converted in prior. The type is not changed when doing this.

Parameters:
name The name of the parameter.
defaultIntValue The value to be used, if the parameter did not exist.
Returns:
The integer value.
Warning:
Since the long type is also used for ints, this might mean a loss of leading digits.

int GetIntValue const char *  name  )  [inline]
 

Returns a integer value of a parameter.

If the parameter is not of integer type, it is converted in prior. The type is not changed when doing this.

Parameters:
name The name of the parameter.
Returns:
The integer value.
Warning:
Since the long type is also used for ints, this might mean a loss of leading digits.

long GetLongValue const char *  name,
long  defaultLongValue
 

Returns a long integer value of a parameter.

If the parameter is not of long integer type, it is converted in prior. The type is not changed when doing this.

Parameters:
name The name of the parameter.
defaultLongValue The value to be used, if the parameter did not exist.
Returns:
The long integer value.

long GetLongValue const char *  name  )  [inline]
 

Returns a long integer value of a parameter.

If the parameter is not of long integer type, it is converted in prior. The type is not changed when doing this.

Parameters:
name The name of the parameter.
Returns:
The long integer value.

const char* GetName  )  [inline]
 

Returns the name of the section.

Returns:
The name of the section.

ConfigParameter* GetParameter const char *  name  ) 
 

Returns the ConfigParameter object for a given name or creates it, if it doesn't exist yet.

Parameters:
name The name of the parameter.
Returns:
The ConfigParameter.

PointeredList* GetParameterNames  )  [inline]
 

Returns a PointeredList of all parameter names in this section.

Returns:
The parameter names as PointeredList.
Warning:
This method creates a PointeredList and expects that it is deleted by the caller.

ConfigSection* GetSection const char *  name  ) 
 

Returns a sub-section of the section.

If the section does not exist, a new ConfigSection is returned. So use this method to create sections as well.

Parameters:
name The name of the section.
Returns:
The section according to the name.

PointeredList* GetSectionNames  )  [inline]
 

Returns a PointeredList of all section names in this section.

Returns:
The section names as PointeredList.
Warning:
This method creates a PointeredList and expects that it is deleted by the caller.

PointeredList* GetSections  )  [inline]
 

Returns a PointeredList of all sections in this section.

Returns:
The sections as PointeredList.
Warning:
This method creates a PointeredList and expects that it is deleted by the caller.

const char* GetStringValue const char *  name,
const char *  defaultStringValue
 

Returns a string value of a parameter.

If the parameter is not of string type, it is converted in prior, as far as this does not mean any memory allocation. If the conversion isn't possible without allocating memory (for example for the integer type), the method returns an empty string.

Parameters:
name The name of the parameter.
defaultStringValue The value to be used, if the parameter did not exist. Its memory is copied, it is no longer used after the call.
Returns:
The string value.
Note:
Do not free or change the return value. Use SetStringValue instead.

const char* GetStringValue const char *  name  )  [inline]
 

Returns a string value of a parameter.

If the parameter is not of string type, it is converted in prior, as far as this does not mean any memory allocation. If the conversion isn't possible without allocating memory (for example for the integer type), the method returns an empty string.

Parameters:
name The name of the parameter.
Returns:
The string value.
Note:
Do not free or change the return value. Use SetStringValue instead.

int GetType const char *  name  )  [inline]
 

Returns the type of a given parameter.

Parameters:
name The name of the parameter.
Returns:
The type of the parameter.

bool HasParameter const char *  name  ) 
 

Returns whether the config section has a parameter with a given name.

Parameters:
name The name of the parameter to be checked.
Returns:
Whether the config section has the parameter.

bool HasSection const char *  name  ) 
 

Returns whether the config section has a sub section with a given name.

Parameters:
name The name of the sub section to be checked.
Returns:
Whether the config section has the sub section.

void SetBoolValue const char *  name,
bool  boolValue
[inline]
 

Sets a boolean parameter for a given name.

Parameters:
name The name of the parameter.
boolValue The new boolean value.

void SetDoubleValue const char *  name,
double  doubleValue
[inline]
 

Sets a double float parameter for a given name.

Parameters:
name The name of the parameter.
doubleValue The new double float value.

void SetIntValue const char *  name,
int  intValue
[inline]
 

Sets a integer parameter for a given name.

Parameters:
name The name of the parameter.
intValue The new integer value.
Note:
This method is provided for better compatibility of the int and long types.

void SetLongValue const char *  name,
long  longValue
[inline]
 

Sets a long integer parameter for a given name.

Parameters:
name The name of the parameter.
longValue The new long integer value.

void SetStringValue const char *  name,
const char *  stringValue
[inline]
 

Sets a string parameter for a given name.

Parameters:
name The name of the parameter.
stringValue The new string value. The method copies the string so its memory is not used after the creation.

bool WriteIndentation class Config::Writer Writer,
int  depth
[static, private]
 

Writes the indentation (tabs) according to the given depth into a file.

Parameters:
Writer The writer to write to.
depth The number of tabs to be written.
Returns:
Whether the writing was successful.

bool WriteTo class Config::Writer Writer,
int  depth,
bool  indent
[private]
 

Writes this section to a file.

Parameters:
Writer The writer to write to.
depth The section nest depth, to indent correctly.
indent Whether to indent values according to their structural depth.
Returns:
Whether the writing was successful.


Member Data Documentation

friend Config [private]
 

Definition at line 407 of file Config.h.

friend HashMap<ConfigSection> [private]
 

Definition at line 408 of file Config.h.

char* Name [private]
 

The name of the section.

Definition at line 422 of file Config.h.

StringKeyHashMap<ConfigParameter>* Parameters [private]
 

The parameters in this section.

Definition at line 427 of file Config.h.

StringKeyHashMap<ConfigSection>* Sections [private]
 

The sub-sections in this section.

Definition at line 432 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