AURobotServers  4
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Uconfig Class Reference

#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]
 

Detailed Description

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.

Constructor & Destructor Documentation

Uconfig::Uconfig ( const char *  filename)
Uconfig::Uconfig ( void  )

References count, iniFileName, and saveOnExit.

Uconfig::~Uconfig ( )

References saveConfig(), and saveOnExit.

Member Function Documentation

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().

void Uconfig::clear ( void  )
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 
)

Double get

References strGet().

Referenced by UCamPar::setCameraParameters().

int Uconfig::doublePut ( const char *  subj,
const char *  key,
const double  value 
)

Double put

References doubleToKeyStr(), MaxCharPerLine, MaxKeyLength, and strPut().

Referenced by UCamPar::savePar().

USubjectKey Uconfig::getIndex ( const char *  subj,
const char *  key 
)
private
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 
)

Member Data Documentation

int Uconfig::count
private
char Uconfig::iniFileName[MaxFileNameLength]

Filename - relative or absolut - where to save the content.

Referenced by readConfig(), saveConfig(), saveConfigAs(), strPut(), and Uconfig().

UConfigItem Uconfig::items[MaxItemsInList]
private
bool Uconfig::saveOnExit

Should content be saved before destruction? If true and filename is set, it will be saved.

Referenced by Uconfig(), and ~Uconfig().


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