CConfigurator Class Reference

#include <Configurator.h>

Collaboration diagram for CConfigurator:

Collaboration graph
[legend]

Detailed Description

Definition at line 119 of file Configurator.h.


Public Member Functions

 CConfigurator (class CConfigurator *parent, char *name, char *value, char *text, size_t textlen)
 Constructor.
 ~CConfigurator (void)
 Destructor.
char * strip_string (char *c)
 Reduce a quoted string to it's real value.
void add_value (char *n, char *v)
 Add a value to our list of values.
char * get_text_value (const char *n)
char * get_text_value (const char *n, const char *def)
 Return a text value, if the name of the value can't be found in our list of values, return def.
bool get_bool_value (const char *n)
bool get_bool_value (const char *n, bool def)
 Return a boolean value, if the name of the value can't be found in our list of values, or if the value isn't valid, return def.
u64 get_num_value (const char *n, bool decimal_suffixes)
u64 get_num_value (const char *n, bool decimal_suffixes, u64 def)
 Return a numeric value, if the name of the value can't be found in our list of values, return def.
classid get_class_id ()
void * get_device ()
int get_flags ()
char * get_myName ()
char * get_myValue ()
CConfiguratorget_myParent ()
void initialize ()
 Determine what device this configurator represents, and instantiate it; then call initialize for our children.

Private Attributes

class CConfiguratorpParent
class CConfiguratorpChildren [25]
int iNumChildren
char * myName
char * myValue
void * myDevice
classid myClassId
int myFlags
int iNumValues
struct CConfigurator::SCfg_Value pValues [50]

Data Structures

struct  SCfg_Value

Constructor & Destructor Documentation

CConfigurator::CConfigurator ( class CConfigurator parent,
char *  name,
char *  value,
char *  text,
size_t  textlen 
)

Constructor.

The portion of the configuration file that corresponds with the device we are the configurator for is passed as text, with a length of textlen. We parse this text portion, creating values and children configurators as needed. If parent is NULL, we are the master configurator, and we will call initialize for our children (probably GUI and System) so they can instantiate the classes that correspond to the devices that they configure for. The children will in turn initialize their children.

Bug:
This needs to be more robust! As it is now, this code was more or less "hacked together" in a few minutes. Also, more comments should be provided to make it more readable.

Definition at line 157 of file Configurator.cpp.

References add_value(), FAILURE_2, FAILURE_3, initialize(), iNumChildren, iNumValues, myFlags, myName, myValue, pChildren, pParent, and strip_string().

CConfigurator::~CConfigurator ( void   ) 

Destructor.

Bug:
This does nothing now; it should:
  • if we are a top-level component (System or GUI) delete the component (which will delete the components children).
  • delete our children.
  • free memory we allocated for values.

Definition at line 484 of file Configurator.cpp.


Member Function Documentation

char * CConfigurator::strip_string ( char *  c  ) 

Reduce a quoted string to it's real value.

Some values are enclosed in double quotes("), in this case, we take off the quotes, and replace all double double quotes ("") with single double quotes ("). Quoting values is particularly useful if values contain forbidden characters such as spaces, quotes, semicolons, etc. e.g. a text like "c:\program files\putty\putty.exe" telnet://localhost:8000 should be quoted as """c: files\putty\putty.exe"" telnet://localhost:8000"

Definition at line 497 of file Configurator.cpp.

Referenced by CConfigurator().

void CConfigurator::add_value ( char *  n,
char *  v 
)

Add a value to our list of values.

Definition at line 528 of file Configurator.cpp.

References iNumValues, CConfigurator::SCfg_Value::name, pValues, and CConfigurator::SCfg_Value::value.

Referenced by CConfigurator().

char* CConfigurator::get_text_value ( const char *  n  )  [inline]

char * CConfigurator::get_text_value ( const char *  n,
const char *  def 
)

Return a text value, if the name of the value can't be found in our list of values, return def.

Definition at line 539 of file Configurator.cpp.

References iNumValues, pValues, and CConfigurator::SCfg_Value::value.

bool CConfigurator::get_bool_value ( const char *  n  )  [inline]

bool CConfigurator::get_bool_value ( const char *  n,
bool  def 
)

Return a boolean value, if the name of the value can't be found in our list of values, or if the value isn't valid, return def.

Valid values are strings that have a first character of:

  • t (true)
  • y (yes, evaluates to true)
  • 1 (evaluates to true)
  • f (false)
  • n (no, evaluates to false)
  • 0 (evaluates to false)

Definition at line 564 of file Configurator.cpp.

References FAILURE_2, iNumValues, and pValues.

u64 CConfigurator::get_num_value ( const char *  n,
bool  decimal_suffixes 
) [inline]

u64 CConfigurator::get_num_value ( const char *  n,
bool  decimal_suffixes,
u64  def 
)

Return a numeric value, if the name of the value can't be found in our list of values, return def.

Definition at line 601 of file Configurator.cpp.

References FAILURE_2, iNumValues, pValues, and CConfigurator::SCfg_Value::value.

classid CConfigurator::get_class_id (  )  [inline]

Definition at line 141 of file Configurator.h.

References myClassId.

void* CConfigurator::get_device (  )  [inline]

Definition at line 142 of file Configurator.h.

References myDevice.

Referenced by initialize().

int CConfigurator::get_flags (  )  [inline]

Definition at line 143 of file Configurator.h.

References myFlags.

Referenced by initialize().

char* CConfigurator::get_myName (  )  [inline]

char* CConfigurator::get_myValue (  )  [inline]

CConfigurator* CConfigurator::get_myParent (  )  [inline]

Definition at line 147 of file Configurator.h.

References pParent.

Referenced by CDisk::CDisk().

void CConfigurator::initialize (  ) 


Field Documentation

Definition at line 151 of file Configurator.h.

Referenced by CConfigurator(), get_myParent(), and initialize().

Definition at line 152 of file Configurator.h.

Referenced by CConfigurator(), and initialize().

Definition at line 153 of file Configurator.h.

Referenced by CConfigurator(), and initialize().

char* CConfigurator::myName [private]

Definition at line 154 of file Configurator.h.

Referenced by CConfigurator(), get_myName(), and initialize().

char* CConfigurator::myValue [private]

Definition at line 155 of file Configurator.h.

Referenced by CConfigurator(), get_myValue(), and initialize().

void* CConfigurator::myDevice [private]

Definition at line 156 of file Configurator.h.

Referenced by get_device(), and initialize().

Definition at line 157 of file Configurator.h.

Referenced by get_class_id(), and initialize().

int CConfigurator::myFlags [private]

Definition at line 158 of file Configurator.h.

Referenced by CConfigurator(), get_flags(), and initialize().


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

SourceForge.net Logo
Project space on SourceForge.net