In file appconf.h:

class BaseConfig

abstract base class config

Inheritance:

BaseConfig


Public Methods

void recordDefaults(Bool enable = TRUE)
activates recording of default values

Public

Constructors and destructor
BaseConfig()
default ctor
virtual ~BaseConfig()
dtor
Set and retrieve current path
virtual void setCurrentPath(const char *szPath = "")
Specify the new current path by its absolute name
virtual void changeCurrentPath(const char *szPath = "")
Change the current path
const char* getCurrentPath() const
Query the current path
static char* normalizePath(const char *szStartPath, const char *szPath)
Resolve "
Enumeration of subgroups/entries
class Enumerator
Class that supports enumeration.
size_t Count() const
return number of elements
const char* operator[](size_t nIndex) const
return the element #nIndex
virtual Enumerator* enumSubgroups() const
Enumerate subgroups of the current group
virtual Enumerator* enumEntries() const
Enumerate entries of the current group
Key access
virtual const char* readEntry(const char *szKey, const char *szDefault = NULL) const
Get the value of an entry, or the default value
long int readEntry(const char *szKey, long int Default) const
Get the value of an entry, or the default value, interpreted as a long integer
double readEntry(const char *szKey, double Default) const
Get the value of an entry, or the default value, interpreted as a double value
virtual Bool writeEntry(const char *szKey, const char *szValue)
Set the value of an entry
Bool writeEntry(const char *szKey, long int Value)
Set the value of an entry to a long int value
Bool writeEntry(const char *szKey, double Value)
Set the value of an entry to a double value
virtual Bool deleteEntry(const char *szKey)
Deletes the entry.
Other functions
virtual Bool flush(Bool = FALSE)
permanently writes changes, returns TRUE on success
Bool isInitialized() const
returns TRUE if object was correctly initialized
Filter functions.
static char* filterOut(const char *szValue)
should be called from writeEntry, returns pointer to dynamic buffer
static char* filterIn(const char *szValue)
should be called from readEntry, returns pointer to dynamic buffer
void expandVariables(Bool bExpand = TRUE)
should environment variables be automatically expanded?
Bool doesExpandVariables(void) const
do environment variables get automatically expanded?

Protected Fields

Bool m_bOk
TRUE if ctor successfully initialized the object
Bool m_bExpandVariables
TRUE if environment variables are to be auto-expanded
Bool m_bRecordDefaults
TRUE if default values are to be recorded

Documentation

abstract base class config
Constructors and destructor

BaseConfig()
default ctor

virtual ~BaseConfig()
dtor

Set and retrieve current path

virtual void setCurrentPath(const char *szPath = "")
Specify the new current path by its absolute name
Parameters:
szPath - name of the group to search by default (created if !exists)

virtual void changeCurrentPath(const char *szPath = "")
Change the current path. Works like 'cd' and supports "..".
Parameters:
szPath - name of the group to search by default (created if !exists)

const char* getCurrentPath() const
Query the current path
Returns:
current '/' separated path

static char* normalizePath(const char *szStartPath, const char *szPath)
Resolve ".." and "/" in the path.
Returns:
Pointer to normalized path (caller should "delete []" it)
Parameters:
Start - path (i.e. current directory)
Relative - path (".." allowed) from start path

void recordDefaults(Bool enable = TRUE)
activates recording of default values
Parameters:
enable - TRUE to activate, FALSE to deactivate

Enumeration of subgroups/entries

class Enumerator
This class allows access to an array of strings, which are entries or group names.
See Also:
enumSubgroups, enumEntries

size_t Count() const
return number of elements

const char* operator[](size_t nIndex) const
return the element #nIndex

virtual Enumerator* enumSubgroups() const
Enumerate subgroups of the current group. Caller must delete the returned pointer. Example of usage:
char **aszGroups;
config.setCurrentPath("mygroup");
BaseConfig::Enumerator *pEnum = config.enumSubgroups();
size_t nGroups = pEnum->Count();
for ( size_t n = 0; n < nGroups; n++ )
cout << "Name of subgorup #" << n << " is " << (*pEnum)[n] << endl;
delete pEnum;
Returns:
Number of subgroups
Parameters:
Pointer - to an array of strings which is allocated by the function
See Also:
Enumerator, setCurrentPath, enumEntries

virtual Enumerator* enumEntries() const
Enumerate entries of the current group
Returns:
Number of entries
See Also:
Enumerator, enumSubgroups

Key access

virtual const char* readEntry(const char *szKey, const char *szDefault = NULL) const
Get the value of an entry, or the default value
Returns:
The value of the key, or defval if not found
Parameters:
szKey - The key to search for.
szDefault - The default value to return if not found.

long int readEntry(const char *szKey, long int Default) const
Get the value of an entry, or the default value, interpreted as a long integer
Returns:
The value of the key converted to long int or the default value.
Parameters:
szKey - The key to search for.
Default - The default value to return if not found.

double readEntry(const char *szKey, double Default) const
Get the value of an entry, or the default value, interpreted as a double value
Returns:
The value of the key converted to double or the default value.
Parameters:
szKey - The key to search for.
Default - The default value to return if not found.

virtual Bool writeEntry(const char *szKey, const char *szValue)
Set the value of an entry
Returns:
TRUE on success, FALSE on failure
Parameters:
szKey - The key whose value to change.
szValue - The new value.

Bool writeEntry(const char *szKey, long int Value)
Set the value of an entry to a long int value
Returns:
TRUE on success, FALSE on failure
Parameters:
szKey - The key whose value to change.
Value - The new value.

Bool writeEntry(const char *szKey, double Value)
Set the value of an entry to a double value
Returns:
TRUE on success, FALSE on failure
Parameters:
szKey - The key whose value to change.
Value - The new value.

virtual Bool deleteEntry(const char *szKey)
Delets the entry. Notice that there is intentionally no such function as deleteGroup: the group is automatically deleted when it's last entry is deleted.
Returns:
TRUE on success, FALSE on failure
Parameters:
szKey - The key to delete

Other functions

virtual Bool flush(Bool = FALSE)
permanently writes changes, returns TRUE on success

Bool isInitialized() const
returns TRUE if object was correctly initialized

Filter functions.
All key values should pass by these functions, derived classes should call them in their read/writeEntry functions. Currently, these functions only escape meta-characters (mainly spaces which would otherwise confuse the parser), but they could also be used to encode/decode key values.

static char* filterOut(const char *szValue)
should be called from writeEntry, returns pointer to dynamic buffer

static char* filterIn(const char *szValue)
should be called from readEntry, returns pointer to dynamic buffer

void expandVariables(Bool bExpand = TRUE)
should environment variables be automatically expanded?

Bool doesExpandVariables(void) const
do environment variables get automatically expanded?

Bool m_bOk
TRUE if ctor successfully initialized the object

Bool m_bExpandVariables
TRUE if environment variables are to be auto-expanded

Bool m_bRecordDefaults
TRUE if default values are to be recorded


Direct child classes:
RegistryConfig
FileConfig

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de