Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

Conf Class Reference

#include <conf.h>

List of all members.

Public Member Functions

const OPENCITY_ERR_CODE Open (const string &fname)
void Close ()
const string & GetValue (const string &key, const string def="")
const OPENCITY_ERR_CODE GetBool (const string &key, bool &rbool, const bool def=false)
const OPENCITY_ERR_CODE GetLint (const string &key, OC_LINT &rlint, const OC_LINT def=0)
const OPENCITY_ERR_CODE GetFloat (const string &key, float &rfloat, const float def=0)

Static Public Member Functions

static OC_CHAR *const RTrim (OC_CHAR *const str)
static OC_CHAR *const LTrim (OC_CHAR *const str)

Private Attributes

map< string, string > _mapData


Detailed Description

Manage the ".conf" file. The parser automatically trim out the spaces around the "=" sign. A ".conf" file is a text file with things like following:

Definition at line 55 of file conf.h.


Member Function Documentation

const OPENCITY_ERR_CODE Conf::GetBool const string &  key,
bool &  rbool,
const bool  def = false
 

Empty value causes the method to return OC_ERR_INVALID and the rbool variable contains an undefied value. The following values are interpreted as false: 0, no, n, off. Anything other than space is interpreted as true

Parameters:
key The key of the element that you what to retrieve the value
rbool The reference to the boolean variable that holds the value
def Default value
Returns:
the value pointed by the given "key"

Definition at line 138 of file conf.cpp.

const OPENCITY_ERR_CODE Conf::GetFloat const string &  key,
float &  rfloat,
const float  def = 0
 

Convert the string specified by the key "key" to float. This method uses the function "strtol()"

Definition at line 211 of file conf.cpp.

const OPENCITY_ERR_CODE Conf::GetLint const string &  key,
OC_LINT &  rlint,
const OC_LINT  def = 0
 

Convert the string specified by the key "key" to long int. This method uses the function "strtol()"

Definition at line 170 of file conf.cpp.

const string & Conf::GetValue const string &  key,
const string  def = ""
 

Return the string which represents the value part of the (key-value) pair

Parameters:
key The key of the element that you what to retrieve the value
def Default value
Returns:
the value pointed by the given "key"

Definition at line 117 of file conf.cpp.

const OPENCITY_ERR_CODE Conf::Open const string &  fname  ) 
 

Open the .conf file specified by its filename

Parameters:
fname The name of the .conf file that you want to open
Returns:
Error code
See also:
main.h

Definition at line 29 of file conf.cpp.

References RTrim().

OC_CHAR *const Conf::RTrim OC_CHAR *const   str  )  [static]
 

Static right and left trim tool

Definition at line 232 of file conf.cpp.

Referenced by Open().


The documentation for this class was generated from the following files:
Generated on Sat Nov 11 10:21:11 2006 for OpenCity by  doxygen 1.4.2