Classes | Static Public Member Functions | Friends

CdcParameters Class Reference

Reads, Parses and holds the Beesnest configuration. More...

#include <DcParameters.h>

List of all members.

Classes

class  CdcNode
 Node in the tree. More...
class  CdcObject

Static Public Member Functions

static bool ReadParams (const char *file_ext) throw (CdcException)
 This static function reads the Parameters file, parses it, and fills the values of the class parameters (map).
static CdcString GetParam (const CdcString &name)
 Return a string from the parameters map.
static CdcString GetParam (const char *name)
static CdcNodeGetNodePointer (const char *name)
 Return a pointer to the node that name is pointing to.
static bool IsUnder (const CdcString &name, const CdcString &value, bool partly=false)
 This function looks for some value under a point in the parameters tree (node).
static bool IsUnder (const char *name, const CdcString &value, bool partly=false)
static CdcString GetFullName (const CdcString &name, const CdcString &start_at)
 This function returns the full parameter name of a parameter with direct name of name.
static int ToInt (const CdcString &str)
 Try to convert a string to an integer.

Friends

bool ExtGetParam (const char *name, char *val, int max_len)
 Every adapter/engine gets a pointer to this function, so it can get values from the configuration database.

Detailed Description

Reads, Parses and holds the Beesnest configuration.


That was silly - I Need to work with a regular XML parser or not with an XML format at all.

This class contains just static data members and functions. it reads parameters from a XML-like file, and stores them for the use of this server.

The format of the Parameters file is similar to a normal XML format, BUT:

All the parameters are stored as strings. There is a function to convert a string to an integer.

The parameters get stored in a map (hash table), and a tree. the name of each parameter is 'field1'->'field2'...
e.g. if the file look like this:

 <Beesnest>
		<Server>
		<Name> Val </Name>
		</Server>
 </Beesnest>
 

The value 'Val' will be stored under the name: "Server->Name"

The user can look for a value under some point in the tree as well.

Author:
Erez Bibi
Version:
1.0

Definition at line 70 of file DcParameters.h.


Member Function Documentation

CdcString CdcParameters::GetFullName ( const CdcString name,
const CdcString start_at 
) [static]

This function returns the full parameter name of a parameter with direct name of name.

E.g. if name is "Format" and start_at is "Server", the returned value will be "Server->Log-File->Format".

Parameters:
nameThe parameter name to look for.
start_atThe place to start the search at.
Returns:
(CdcString) The full name of this parameter.

Definition at line 168 of file DcParameters.cpp.

CdcParameters::CdcNode * CdcParameters::GetNodePointer ( const char *  name ) [static]

Return a pointer to the node that name is pointing to.

Parameters:
nameThe name of the parameter (node).
Returns:
(CdcNode) Pointer to a node or NULL.

Definition at line 124 of file DcParameters.cpp.

CdcString CdcParameters::GetParam ( const CdcString name ) [static]

Return a string from the parameters map.

Parameters:
nameThe name of the parameter.
Returns:
(CdcString) the value of the parameter (as string) or an empty string.

Definition at line 104 of file DcParameters.cpp.

static CdcString CdcParameters::GetParam ( const char *  name ) [inline, static]

Definition at line 170 of file DcParameters.h.

bool CdcParameters::IsUnder ( const CdcString name,
const CdcString value,
bool  partly = false 
) [static]

This function looks for some value under a point in the parameters tree (node).

Parameters:
nameThe point to start look for the value. It should be built as "Field1->Field2->...".
valueThe value to look for.
partlyTrue if looking for part of a value. False is the default.
Returns:
(bool) True if this value exists under this point.

Definition at line 158 of file DcParameters.cpp.

static bool CdcParameters::IsUnder ( const char *  name,
const CdcString value,
bool  partly = false 
) [inline, static]

Definition at line 193 of file DcParameters.h.

bool CdcParameters::ReadParams ( const char *  file_ext ) throw (CdcException) [static]

This static function reads the Parameters file, parses it, and fills the values of the class parameters (map).

Parameters:
file_extThe files extension to read, as string.
Returns:
(bool) True if the Parameters file format is Well-Formed (according to my rules...).
Exceptions:
(CdcException)if the Parameters file format is wrong.

Definition at line 30 of file DcParameters.cpp.

int CdcParameters::ToInt ( const CdcString str ) [static]

Try to convert a string to an integer.

Parameters:
strThe string to convert.
Returns:
(int) The value of the string or 0 if it cannot be converted

Definition at line 205 of file DcParameters.cpp.


Friends And Related Function Documentation

bool ExtGetParam ( const char *  name,
char *  val,
int  max_len 
) [friend]

Every adapter/engine gets a pointer to this function, so it can get values from the configuration database.

Parameters:
nameThe name (path) of the required value.
valBuffer to put the value in.
max_lenThe size of this buffer.
Returns:
True if the parameter was found in the database.

Definition at line 114 of file DcParameters.cpp.


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