Main Page Modules Class Hierarchy Compound List File List Compound Members

# cStructDescriptor Class Reference

`#include <cstruct.h>`

Inheritance diagram for cStructDescriptor::

List of all members.

## Public Types
enum | { FT_BASIC, FT_SPECIAL, FT_STRUCT, FT_BASIC_ARRAY, FT_SPECIAL_ARRAY, FT_STRUCT_ARRAY, FT_INVALID }
| Field types. More...
## Public Methods
Constructors, destructor, assignment.
| cStructDescriptor (void *_p=NULL)
| cStructDescriptor (const cStructDescriptor &cs)
virtual | ~cStructDescriptor ()
cStructDescriptor& | operator= (const cStructDescriptor &)
Getting and setting client object.
void | setStruct (void *_p)
void* | getStruct () const
Querying and setting fields of the client object.
virtual int | getFieldCount ()=0
virtual const char* | getFieldName (int field)=0
virtual int | getFieldType (int field)=0
virtual const char* | getFieldTypeString (int field)=0
virtual const char* | getFieldEnumName (int field)=0
virtual int | getArraySize (int field)=0
virtual bool | getFieldAsString (int field, int i, char *buf, int bufsize)=0
virtual bool | setFieldAsString (int field, int i, const char *value)=0
virtual sFieldWrapper* | getFieldWrapper (int field, int i)=0
virtual const char* | getFieldStructName (int field)=0
virtual void* | getFieldStructPointer (int field, int i)=0
## Static Public Methods
Getting descriptor for an object or a struct.
bool | hasDescriptor (const char *classname)
cStructDescriptor* | createDescriptorFor (cObject *obj)
cStructDescriptor* | createDescriptorFor (const char *classname, void *p)

## Detailed Description

Abstract base class for structure description classes, used mainly with message subclassing.

FIXME: explain client object, fieldwrapper, etc.

The copy constructor, dup() and the assignment operator are redefined to raise an error (throw cException), since they would be of no use in subclasses.

See also:
  sFieldWrapper

## Member Enumeration Documentation

anonymous enum

  | Field types. Enumeration values:
  FT_BASIC | int, long, double, bool, char*, char[].
  FT_SPECIAL | another data type that requires special presentation (e.g IP address).
  FT_STRUCT | embedded structure, for which there's another cStructDescriptor.
  FT_BASIC_ARRAY | array of FT_BASIC.
  FT_SPECIAL_ARRAY | array of FT_SPECIAL.
  FT_STRUCT_ARRAY | array of FT_STRUCT.
  FT_INVALID | invalid type (signals error condition).

## Constructor & Destructor Documentation

cStructDescriptor::cStructDescriptor ( | void * _p = NULL )`[inline]`

| Constructor. The argument is the client object.

cStructDescriptor::cStructDescriptor ( | const cStructDescriptor & cs )`[inline]`

| Copy constructor.

cStructDescriptor::~cStructDescriptor ( | )`[virtual]`

| Destructor.

## Member Function Documentation

cStructDescriptor * cStructDescriptor::createDescriptorFor ( | const char * classname,
| void * p )`[static]`

| Creates and returns a descriptor object for the struct passed as argument. The type of the descriptor object will be determined from the 1st argument, classname. The passed struct will be the client object for the descriptor object.

cStructDescriptor * cStructDescriptor::createDescriptorFor ( | cObject * obj )`[static]`

| Creates and returns a descriptor object for the object passed as argument. The type of the descriptor object will be determined from the className() of 'obj'. 'obj' will be the client object for the descriptor object.

int cStructDescriptor::getArraySize ( | int field )`[pure virtual]`

| Must be redefined in subclasses to return the array size of a field in the client object. If the field is not an array, it should return 0.

bool cStructDescriptor::getFieldAsString ( | int field,
| int i,
| char * buf,
| int bufsize )`[pure virtual]`

| Must be redefined in subclasses to return the value of a basic field (of type FT_BASIC(_ARRAY)) in the client object as a string. Returns true if no error occurred, false otherwise. FIXME: what if called for non-basic fields?

int cStructDescriptor::getFieldCount ( | )`[pure virtual]`

| Must be redefined in subclasses to return the number of fields in the client object.

const char * cStructDescriptor::getFieldEnumName ( | int field )`[pure virtual]`

| Returns the enum name associated with the field. This makes only sense with integer-type fields (short, int, long, etc.). Returns NULL if there's no associated enum. See also: cEnum

const char * cStructDescriptor::getFieldName ( | int field )`[pure virtual]`

| Must be redefined in subclasses to return the name of a field in the client object. The argument must be in the 0..getFieldCount()-1 range, inclusive.

const char * cStructDescriptor::getFieldStructName ( | int field )`[pure virtual]`

| Must be redefined in subclasses to return the type name of an FT_STRUCT(_ARRAY) field in the client object. The return value may be used then as classname to create a descriptor object for this structure field.

void * cStructDescriptor::getFieldStructPointer ( | int field,
| int i )`[pure virtual]`

| Must be redefined in subclasses to return the pointer of an FT_STRUCT(_ARRAY) field in the client object. The return value may be used then as client object pointer to create a descriptor object for this structure field.

int cStructDescriptor::getFieldType ( | int field )`[pure virtual]`

| Must be redefined in subclasses to return the type of a field in the client object. The argument must be in the 0..getFieldCount()-1 range, inclusive. FIXME: type constants!

const char * cStructDescriptor::getFieldTypeString ( | int field )`[pure virtual]`

| Must be redefined in subclasses to return the type of a field in the client object as a string. The argument must be in the 0..getFieldCount()-1 range, inclusive.

sFieldWrapper * cStructDescriptor::getFieldWrapper ( | int field,
| int i )`[pure virtual]`

| Must be redefined in subclasses to return a wrapper for an FT_SPECIAL(_ARRAY) field in the client object. There's no corresponding setFieldWrapper() method -- setting the field value should can take place via the wrapper object returned here. * Returns NULL if no associated wrapper is defined for this field.

void * cStructDescriptor::getStruct ( | ) const`[inline]`

| Returns client object.

bool cStructDescriptor::hasDescriptor ( | const char * classname )`[static]`

| Returns true if the class 'classname' has an associated cStructDescriptor object.

cStructDescriptor & cStructDescriptor::operator= ( | const cStructDescriptor & )`[inline]`

| Assignment is not supported by this class: this method throws a cException when called.

bool cStructDescriptor::setFieldAsString ( | int field,
| int i,
| const char * value )`[pure virtual]`

| Must be redefined in subclasses to set the value of a basic field (of type FT_BASIC(_ARRAY)) in the client object as a string. Returns true if no error occurred, false otherwise. FIXME: what if called for non-basic fields?

void cStructDescriptor::setStruct ( | void * _p )`[inline]`

| Sets client object.

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

- cstruct.h