Reads, Parses and holds the Beesnest configuration. More...
#include <DcParameters.h>
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 CdcNode * | GetNodePointer (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. |
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.
Definition at line 70 of file DcParameters.h.
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".
name | The parameter name to look for. |
start_at | The place to start the search at. |
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.
name | The name of the parameter (node). |
Definition at line 124 of file DcParameters.cpp.
Return a string from the parameters map.
name | The name of the parameter. |
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).
name | The point to start look for the value. It should be built as "Field1->Field2->...". |
value | The value to look for. |
partly | True if looking for part of a value. False is the default. |
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).
file_ext | The files extension to read, as string. |
(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.
str | The string to convert. |
Definition at line 205 of file DcParameters.cpp.
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.
name | The name (path) of the required value. |
val | Buffer to put the value in. |
max_len | The size of this buffer. |
Definition at line 114 of file DcParameters.cpp.