HRESULT CFastContainerUtil::SetPropertyValue()

in src/foundation_library/FastContainerUtil.cpp [199:347]


HRESULT CFastContainerUtil::SetPropertyValue(
    foundation::PropertyType propertyType,
    LPVOID pSlotValue,
    foundation::IInspectable *value)
{
    ClearPropertySlot(propertyType,pSlotValue);
    if ((propertyType & 0x400) != 0)
    {
        if (value == nullptr)
        {
            return S_OK;
        }
		foundation::library::_ArrayPropertyValueSlot arrayPropertyValueSlot;
        arrayPropertyValueSlot._size = 0;
        arrayPropertyValueSlot._pArrayBuffer = nullptr;

        PropertyType itemArrayType = (PropertyType)(propertyType & 0xff);
        UINT32 *pSize = &arrayPropertyValueSlot._size;
        LPVOID *ppArrayBufferPtr = &arrayPropertyValueSlot._pArrayBuffer;

        switch (itemArrayType)
        {
        case PropertyType_UInt8:
            _IFR_(pv_util::GetUInt8Array(
                value, 
                pSize, 
                reinterpret_cast<BYTE **>(ppArrayBufferPtr)));
            break;
        case PropertyType_Int16:
            _IFR_(pv_util::GetInt16Array(
                value, 
                pSize, 
                reinterpret_cast<INT16 **>(ppArrayBufferPtr)));
            break;
        case PropertyType_UInt16:
            _IFR_(pv_util::GetUInt16Array(
                value, 
                pSize, 
                reinterpret_cast<UINT16 **>(ppArrayBufferPtr)));
            break;
        case PropertyType_Int32:
            _IFR_(pv_util::GetInt32Array(
                value, 
                pSize, 
                reinterpret_cast<INT32 **>(ppArrayBufferPtr)));
            break;
        case PropertyType_UInt32:
            _IFR_(pv_util::GetUInt32Array(
                value, 
                pSize, 
                reinterpret_cast<UINT32 **>(ppArrayBufferPtr)));
            break;
        case PropertyType_Boolean:
            _IFR_(pv_util::GetBooleanArray(
                value, 
                pSize, 
                reinterpret_cast<boolean **>(ppArrayBufferPtr)));
            break;
        case PropertyType_String:
            _IFR_(pv_util::GetStringArray(
                value, 
                pSize, 
                reinterpret_cast<HSTRING **>(ppArrayBufferPtr)));
            break;
        case PropertyType_Inspectable:
            _IFR_(pv_util::GetInspectableArray(
                value, 
                pSize, 
                reinterpret_cast<foundation::IInspectable ***>(ppArrayBufferPtr)));
            break;
        case PropertyType_Single:
            _IFR_(pv_util::GetSingleArray(
                value, 
                pSize, 
                reinterpret_cast<FLOAT **>(ppArrayBufferPtr)));
            break;
        case PropertyType_Double:
            _IFR_(pv_util::GetDoubleArray(
                value, 
                pSize, 
                reinterpret_cast<DOUBLE **>(ppArrayBufferPtr)));
            break;
        case PropertyType_Guid:
            _IFR_(pv_util::GetGuidArray(
                value, 
                pSize, 
                reinterpret_cast<GUID **>(ppArrayBufferPtr)));
            break;
        case PropertyType_DateTime:
            _IFR_(pv_util::GetDateTimeArray(
                value, 
                pSize, 
                reinterpret_cast<DateTime **>(ppArrayBufferPtr)));
            break;
        default:
            foundation_assert(false);
            return E_NOTIMPL;
        }
        WriteSlotValue<foundation::library::_ArrayPropertyValueSlot>(pSlotValue, &arrayPropertyValueSlot);
    }
    else
    {
        switch (propertyType)
        {
        case PropertyType_UInt8:
            return SetSlotValue<BYTE>(value,pSlotValue);
        case PropertyType_Int16:
            return SetSlotValue<INT16>(value, pSlotValue);
        case PropertyType_UInt16:
            return SetSlotValue<UINT16>(value, pSlotValue);
        case PropertyType_Int32:
            return SetSlotValue<INT32>(value, pSlotValue);
        case PropertyType_UInt32:
            return SetSlotValue<UINT32>(value, pSlotValue);
        case PropertyType_Int64:
            return SetSlotValue<INT64>(value, pSlotValue);
        case PropertyType_UInt64:
            return SetSlotValue<UINT64>(value, pSlotValue);
        case PropertyType_Boolean:
            {
                boolean boolValue;
                _IFR_(pv_util::GetBooleanValue(value, &boolValue));
                WriteSlotValue(pSlotValue, &boolValue);
                return S_OK;
            }
        case PropertyType_String:
            return SetSlotValue<HSTRING>(value, pSlotValue);
        case PropertyType_Inspectable:
            WriteSlotValue(pSlotValue, &value);
            if (value)
            {
                (value)->AddRef();
            }
            return S_OK;
        case PropertyType_Single:
            return SetSlotValue<FLOAT>(value, pSlotValue);
        case PropertyType_Double:
            return SetSlotValue<DOUBLE>(value, pSlotValue);
        case PropertyType_Guid:
            return SetSlotValue<GUID>(value, pSlotValue);
        case PropertyType_DateTime:
            return SetSlotValue<DateTime>(value, pSlotValue);
        default:
            foundation_assert(false);
            return E_NOTIMPL;
        }
    }
    return S_OK;
}