addProtectedField
Using addProtectedField
addProtectedField( name, type, offset(className, fieldName), setFunction, getFunction, writeFunction, description );Example
void MyObjectClass::initPersistFields()
{
Parent::initPersistFields();
addProtectedField( "name", TypeString, offset(MyObjectClass, mHeight), &setName, &getName, "The name of the object" );
}
bool MyObjectClass::setName(void *obj, const char *array, const char *data)
{
MyObjectClass* myObj = static_cast<MyObjectClass*>(obj);
if (myObj )
myObj->setName(data); //Call to our normal class set function
return false;
}
const char* MyObjectClass::getName(void* obj, const char* data)
{
MyObjectClass* myObj = static_cast<MyObjectClass*>(obj);
//This lets us check if we have a valid name, and if not, return
//a sane value
if(myObj->getName())
return myObj->getName(); //The value is good, so use the normal class get function
return StringTable::EmptyString;
}Last updated