Difference between revisions of "OBJECT SETDATA()"
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
Line 34: | Line 34: | ||
</code> | </code> | ||
− | Example in 'C'object: | + | Example in 'C' object: |
<code lang="c"> | <code lang="c"> |
Revision as of 12:18, 27 March 2009
PURPOSE
Set user defined data
SYNONYM
None
SYNOPSIS
#include "dbapi.h" OBJECT_SETDATA(userdata) <input parameters> void *userdata; /* Pointer to a user defined data area */ <output parameters> none
DESCRIPTION
The OBJECT_SETDATA() macro is used assign a user defined data area to an instantiated object. This data area can point to any type of data that can be returned with the OBJECT_GETDATA() macro for the life of the instantiated object.
EXAMPLE
The following example sets the data area from the constructor in a class called clsMyClass.
Example Recital program:
test = newobject("myclass")
Example in 'C' object:
#include "dbapi.h" /* Define constructor method */ DEFINE_METHOD(clsMyClass, Constructor) { struct example_data *objectDataArea; /* Allocate memory for objects objectData area */ objectDataArea = (struct example_data *) malloc(sizeof(struct example_data)); if (objectDataArea == NULL) return(-1); /* Assign the default property values */ strcpy(objectDataArea->prop_charvalue, "Test API object"); objectDataArea->prop_numvalue = 15.2827; objectDataArea->prop_logvalue = 'F'; strcpy(objectDataArea->prop_datevalue, DATE_DATE()); strcpy(objectDataArea->prop_timevalue, DATE_DATETIME()); strcpy(objectDataArea->prop_currvalue, "15.2827"); strcpy(objectDataArea->object_name, "APIobject"); objectDataArea->prop_objvalue = OBJECT_NEW(objectDataArea->object_name, "exception", NULL); /* Set the object objectData area */ OBJECT_SETDATA((char *)objectDataArea); return(0); }
SEE ALSO
DEFINE_CLASS(), DEFINE_METHOD(), DEFINE_PROPERTYGET(), DEFINE_PROPERTYSET(), DISPATCH_FACTORY(), DISPATCH_METHOD(), DISPATCH_PROPGET(), DISPATCH_PROPSET(), OBJECT_ASSIGN(), OBJECT_DELETE(), OBJECT_GETARG(), OBJECT_GETARGC(), OBJECT_GETDATA(), OBJECT_GETOBJECT(), OBJECT_GETPARAMETER(), OBJECT_GETPROPERTY(), OBJECT_GETTYPE(), OBJECT_GETVALUE(), OBJECT_NEW(), OBJECT_RETERROR(), OBJECT_RETPROPERTY(), OBJECT_RETRESULT(), OBJECT_SETARG(), OBJECT_SETPROPERTY()