AURobotServers
4
|
#include <conf.h>
Public Member Functions | |
bool | boolGet (const char *subj, const char *key, const bool def) |
int | boolPut (const char *subj, const char *key, const bool value) |
void | clear (void) |
double | doubleGet (const char *subj, const char *key, const double def) |
int | doublePut (const char *subj, const char *key, const double value) |
bool | HaveSpaceFor (int lines) |
int | intGet (const char *subj, const char *key, const int def) |
int | intPut (const char *subj, const char *key, const int value) |
int | readConfig (const char *filename) |
int | readConfig (void) |
int | saveConfig (void) |
int | saveConfigAs (const char *filename) |
const char * | strGet (const char *subj, const char *key, const char *def=NULL) |
int | strPut (const char *subj, const char *key, const char *value) |
Uconfig (const char *filename) | |
Uconfig (void) | |
~Uconfig () | |
Public Attributes | |
char | iniFileName [MaxFileNameLength] |
bool | saveOnExit |
Private Member Functions | |
USubjectKey | getIndex (const char *subj, const char *key) |
Private Attributes | |
int | count |
UConfigItem | items [MaxItemsInList] |
The config class is a string-based registry database, that primarily is used to load and store configuration information to and from disk. The format is subject-key based:
[subject]
key=value
Methodes for bool, integer, string and double are implemented.
Uconfig::Uconfig | ( | const char * | filename | ) |
References count, iniFileName, MaxFileNameLength, readConfig(), and saveOnExit.
Uconfig::Uconfig | ( | void | ) |
References count, iniFileName, and saveOnExit.
Uconfig::~Uconfig | ( | ) |
References saveConfig(), and saveOnExit.
bool Uconfig::boolGet | ( | const char * | subj, |
const char * | key, | ||
const bool | def | ||
) |
Get a boolean variable. If the value is "false" ot 0 (zero) then false is returned otherwise true is returned. If no value is found, then the default value is returned.
References strGet().
int Uconfig::boolPut | ( | const char * | subj, |
const char * | key, | ||
const bool | value | ||
) |
Save value as either "true" or "false" Returns -1 if failed (no space) or some non-negative value if successful.
References strPut().
|
inline |
Clear content of configuration structure
References getIndex(), readConfig(), saveConfig(), and saveConfigAs().
Referenced by readConfigFile().
double Uconfig::doubleGet | ( | const char * | subj, |
const char * | key, | ||
const double | def | ||
) |
int Uconfig::doublePut | ( | const char * | subj, |
const char * | key, | ||
const double | value | ||
) |
Double put
References doubleToKeyStr(), MaxCharPerLine, MaxKeyLength, and strPut().
Referenced by UCamPar::savePar().
|
private |
References count, USubjectKey::intKey, USubjectKey::intSubj, items, and MaxCharPerLine.
bool Uconfig::HaveSpaceFor | ( | int | lines | ) |
Check to see if there is additional space for this many lines
References count, and MaxItemsInList.
int Uconfig::intGet | ( | const char * | subj, |
const char * | key, | ||
const int | def | ||
) |
integer get
References strGet().
int Uconfig::intPut | ( | const char * | subj, |
const char * | key, | ||
const int | value | ||
) |
Integer put
References MaxCharPerLine, and strPut().
int Uconfig::readConfig | ( | const char * | filename | ) |
Clear and read data from this file
References iniFileName, MaxFileNameLength, and readConfig().
int Uconfig::readConfig | ( | void | ) |
Read file with name in iniFileName
References count, iniFileName, items, MaxCharPerLine, MaxItemsInList, and UConfigItem::type.
Referenced by clear(), readConfig(), and Uconfig().
int Uconfig::saveConfig | ( | void | ) |
Save configuration now
References count, iniFileName, and items.
Referenced by clear(), saveConfigAs(), and ~Uconfig().
int Uconfig::saveConfigAs | ( | const char * | filename | ) |
Change name and save now under the new name now
References iniFileName, MaxFileNameLength, and saveConfig().
Referenced by clear().
const char * Uconfig::strGet | ( | const char * | subj, |
const char * | key, | ||
const char * | def = NULL |
||
) |
Get string (pointer) to configuration sring
References getIndex(), USubjectKey::intKey, items, and UConfigItem::line.
Referenced by boolGet(), doubleGet(), intGet(), UTime::LoadFromReg(), UPosition::LoadFromReg(), and testPathSettings().
int Uconfig::strPut | ( | const char * | subj, |
const char * | key, | ||
const char * | value | ||
) |
Save this string as new key value
References count, getIndex(), iniFileName, USubjectKey::intKey, USubjectKey::intSubj, items, UConfigItem::line, MaxCharPerLine, MaxItemsInList, and UConfigItem::type.
Referenced by boolPut(), doublePut(), intPut(), UTime::SaveToReg(), and UPosition::SaveToReg().
|
private |
Referenced by getIndex(), HaveSpaceFor(), readConfig(), saveConfig(), strPut(), and Uconfig().
char Uconfig::iniFileName[MaxFileNameLength] |
Filename - relative or absolut - where to save the content.
Referenced by readConfig(), saveConfig(), saveConfigAs(), strPut(), and Uconfig().
|
private |
Referenced by getIndex(), readConfig(), saveConfig(), strGet(), and strPut().
bool Uconfig::saveOnExit |
Should content be saved before destruction? If true and filename is set, it will be saved.
Referenced by Uconfig(), and ~Uconfig().