Arg Class Reference
[Kernel Module]

#include <arg.h>

List of all members.


Detailed Description

Encapsulates a typed argument (float, int, bool, string, object pointer or array) into a uniform C++ class.

Public Types

enum  Type {
  AT_VOID, AT_INT, AT_FLOAT, AT_STRING,
  AT_BOOL, AT_OBJECT, AT_ARRAY
}

Public Member Functions

 Arg ()
 Arg (const Arg &rhs)
 ~Arg ()
void Delete ()
void Copy (const Arg &rhs)
void Copy (va_list *marker)
void Reset (char c)
Type GetType () const
bool operator== (const Arg &rhs) const
bool operator!= (const Arg &rhs) const
Argoperator= (const Arg &rhs)
void SetI (int i)
void SetB (bool b)
void SetF (float f)
void SetS (const char *s)
void SetO (void *)
void SetA (Arg *_a, int len)
int GetI () const
bool GetB () const
float GetF () const
const char * GetS () const
void * GetO () const
int GetA (Arg *&) const

Static Public Member Functions

static bool IsValidArg (char c)
static bool IsVoid (char c)

Private Attributes

Type type
union {
   int   i
   bool   b
   float   f
   char *   s
   void *   o
   Arg *   a
}; 
int arr_len
 Number of nArgs in array. Only used for AT_LIST type.

Member Enumeration Documentation

enum Arg::Type

Enumerator:
AT_VOID 
AT_INT 
AT_FLOAT 
AT_STRING 
AT_BOOL 
AT_OBJECT 
AT_ARRAY 


Constructor & Destructor Documentation

Arg::Arg (  )  [inline]

The default constructor will initialize the arg type to AT_VOID

Arg::Arg ( const Arg rhs  )  [inline]

The copy constructor simply calls Arg::Copy()

Parameters:
rhs reference to Arg object to be copied

Arg::~Arg (  )  [inline]

Destructor.


Member Function Documentation

void Arg::Delete (  )  [inline]

Deletes content, sets type to AT_VOID.

void Arg::Copy ( const Arg rhs  )  [inline]

Copies contents. Only calls delete if necessary to avoid memory allocation overhead.

Parameters:
rhs reference to Arg object to be copied

void Arg::Copy ( va_list *  marker  )  [inline]

Copies contents from variable argument list marker. The type of the variable is known by the this->type.

Parameters:
marker va_list parameter.

void Arg::Reset ( char  c  )  [inline]

Sets type corresponding to data type character and reset arg contents.

Arg::Type Arg::GetType (  )  const [inline]

Returns the argument type of the object, which is one of AT_VOID - unitialized AT_INT - integer AT_BOOL - boolean AT_FLOAT - float AT_STRING - string AT_OBJECT - pointer to object AT_ARRAY - array of Args

Returns:
Arg type.

bool Arg::operator== ( const Arg rhs  )  const [inline]

Checks whether data type and contents of the object are identical.

bool Arg::operator!= ( const Arg rhs  )  const [inline]

Checks whether data type and contents of the object are not identical.

Arg & Arg::operator= ( const Arg rhs  )  [inline]

Copies content from another Arg variable.

void Arg::SetI ( int  _i  )  [inline]

Sets the contents to an integer, and sets the arg type to AT_INT.

Parameters:
_i The integer.

void Arg::SetB ( bool  _b  )  [inline]

Sets the contents to a bool value, and set the arg type to AT_BOOL.

Parameters:
_b The bool value.

void Arg::SetF ( float  _f  )  [inline]

Sets the contents to a float value, and sets the arg type to AT_FLOAT.

Parameters:
_f The float value.

void Arg::SetS ( const char *  _s  )  [inline]

Sets the contents to a string, and sets the arg type to AT_STRING. The string is duplicated internally.

Parameters:
_s The string.

void Arg::SetO ( void *  _o  )  [inline]

Sets the contents to an object pointer, and sets the arg type to AT_OBJECT. The pointer is NOT safe (if the object is destroyed, the pointer points to Nirvana).

Parameters:
_o The object pointer.

void Arg::SetA ( Arg _a,
int  len 
) [inline]

Sets the contents to an array of other nArgs, and sets the arg type to AT_ARRAY. The array is NOT duplicated!

Parameters:
_a pointer to array of Arg
len length of array

int Arg::GetI (  )  const [inline]

Returns the integer content of the object. Throws assertion if not set to an integer.

Returns:
The integer value.

bool Arg::GetB (  )  const [inline]

Returns the bool content of the object. Throws assertion if not set to a bool.

Returns:
The bool value.

float Arg::GetF (  )  const [inline]

Returns the float content of the object. Throws assertion if not set to a float.

Returns:
The float value.

const char * Arg::GetS (  )  const [inline]

Returns the string content of the object. Throws assertion if not set to a string.

Returns:
The string pointer.

void * Arg::GetO (  )  const [inline]

Returns the object pointer content of the object. Throws assertion if not set to an object pointer.

Returns:
The object pointer.

int Arg::GetA ( Arg *&  _a  )  const [inline]

Returns the Arg array content of the object. Throws assertion if not set to a list.

Parameters:
_a Pointer to Arg array. Will be set by this function
Returns:
The length of the array.

bool Arg::IsValidArg ( char  c  )  [inline, static]

Checks if the provided data type character is a valid argument.

bool Arg::IsVoid ( char  c  )  [inline, static]

Checks if the provided data type character is void.


Member Data Documentation

Type Arg::type [private]

int Arg::i

bool Arg::b

float Arg::f

char* Arg::s

void* Arg::o

Arg* Arg::a

union { ... } [private]

int Arg::arr_len [private]

Number of nArgs in array. Only used for AT_LIST type.


The documentation for this class was generated from the following file:
Generated on Sat Oct 20 14:47:31 2007 for Dark Oberon by  doxygen 1.5.3