const char* IPropertySet::GetSTRING(const void* pData, int nIndex) { assert(nIndex>=0 && nIndex<PropertyCount()); if(nIndex<0 || nIndex>=PropertyCount()) return NULL; IProperty* pInfo = GetProperty(nIndex); assert(pInfo->GetType()==PROPERTY_TYPE_STRING); if(pInfo->GetType()!=PROPERTY_TYPE_STRING) return NULL; return (const char*)pData + pInfo->GetOffset(); }
unsigned int IPropertySet::GetDWORD(const void* pData, int nIndex) { assert(nIndex>=0 && nIndex<PropertyCount()); if(nIndex<0 || nIndex>=PropertyCount()) return -1; IProperty* pInfo = GetProperty(nIndex); assert(pInfo->GetType()==PROPERTY_TYPE_DWORD); if(pInfo->GetType()!=PROPERTY_TYPE_DWORD) return -1; return *((unsigned int*)((char*)pData + pInfo->GetOffset())); }
float IPropertySet::GetFLOAT(const void* pData, int nIndex) { assert(nIndex>=0 && nIndex<PropertyCount()); if(nIndex<0 || nIndex>=PropertyCount()) return -1; IProperty* pInfo = GetProperty(nIndex); assert(pInfo->GetType()==PROPERTY_TYPE_FLOAT); if(pInfo->GetType()!=PROPERTY_TYPE_FLOAT) return -1; return *((float*)((char*)pData + pInfo->GetOffset())); }
bool IPropertySet::SetValue(void* pData, int nIndex, char Value) { assert(nIndex>=0 && nIndex<PropertyCount()); if(nIndex<0 || nIndex>=PropertyCount()) return false; IProperty* pInfo = GetProperty(nIndex); assert(pInfo->GetType()==PROPERTY_TYPE_CHAR); if(pInfo->GetType()!=PROPERTY_TYPE_CHAR) return false; *((char*)((char*)pData + pInfo->GetOffset())) = Value; return true; }
bool IPropertySet::SetValue(void* pData, int nIndex, const char* Value) { assert(nIndex>=0 && nIndex<PropertyCount()); if(nIndex<0 || nIndex>=PropertyCount()) return false; IProperty* pInfo = GetProperty(nIndex); assert(pInfo->GetType()==PROPERTY_TYPE_FLOAT); if(pInfo->GetType()!=PROPERTY_TYPE_FLOAT) return false; unsigned int len = strlen(Value); assert(len<=pInfo->GetSize()); if(len>pInfo->GetSize()) return false; memcpy((char*)pData+pInfo->GetOffset(), Value, len+1); return true; }