// You cannot instantiate a pure BContactField // so this method help to unflatten the correct // derived class BContactField* BContactField::UnflattenChildClass(const void* from, ssize_t size) { BMemoryIO data(from, size); type_code childType; data.Read(&childType, sizeof(childType)); ObjectDeleter<BContactField> deleter; BContactField* child = NULL; switch (childType) { case B_CONTACT_NAME: case B_CONTACT_NICKNAME: case B_CONTACT_EMAIL: case B_CONTACT_NOTE: case B_CONTACT_ORGANIZATION: case B_CONTACT_IM: case B_CONTACT_URL: case B_CONTACT_PHONE: child = new BStringContactField(childType); break; case B_CONTACT_ADDRESS: child = new BAddressContactField(); break; case B_CONTACT_PHOTO: child = new BPhotoContactField(); break; default: return NULL; } if (child == NULL) return NULL; status_t ret = child->Unflatten(B_CONTACT_FIELD_TYPE, from, size); if (ret == B_OK) return child; deleter.SetTo(child); return NULL; }
// You cannot instantiate a pure BContactField // so this method help to unflatten the correct // derived class BContactField* BContactField::UnflattenChildClass(const void* from, ssize_t size) { BMemoryIO data(from, size); type_code childType; data.Read(&childType, sizeof(childType)); ObjectDeleter<BContactField> deleter; BContactField* child = NULL; child = BContactField::InstantiateChildClass(childType); if (child == NULL) return NULL; status_t ret = child->Unflatten(B_CONTACT_FIELD_TYPE, from, size); if (ret == B_OK) return child; deleter.SetTo(child); return NULL; }