#include <arg.h>
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 |
| Arg & | operator= (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. | |
| enum Arg::Type |
| Arg::Arg | ( | ) | [inline] |
The default constructor will initialize the arg type to AT_VOID
| Arg::Arg | ( | const Arg & | rhs | ) | [inline] |
| Arg::~Arg | ( | ) | [inline] |
Destructor.
| 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.
| 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.
| 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
| 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.
| void Arg::SetI | ( | int | _i | ) | [inline] |
Sets the contents to an integer, and sets the arg type to AT_INT.
| _i | The integer. |
| void Arg::SetB | ( | bool | _b | ) | [inline] |
Sets the contents to a bool value, and set the arg type to AT_BOOL.
| _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.
| _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.
| _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).
| _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!
| _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.
| bool Arg::GetB | ( | ) | const [inline] |
Returns the bool content of the object. Throws assertion if not set to a bool.
| float Arg::GetF | ( | ) | const [inline] |
Returns the float content of the object. Throws assertion if not set to a float.
| const char * Arg::GetS | ( | ) | const [inline] |
Returns the string content of the object. Throws assertion if not set to a string.
| void * Arg::GetO | ( | ) | const [inline] |
Returns the object pointer content of the object. Throws assertion if not set to an object pointer.
| int Arg::GetA | ( | Arg *& | _a | ) | const [inline] |
| 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.
| int Arg::i |
| bool Arg::b |
| float Arg::f |
| char* Arg::s |
| void* Arg::o |
union { ... } [private] |
int Arg::arr_len [private] |
Number of nArgs in array. Only used for AT_LIST type.
1.5.3