void ImplAAFTypeDefString::internalize(const OMByte* externalBytes, OMUInt32 externalBytesSize, OMByte* internalBytes, OMUInt32 internalBytesSize, OMByteOrder byteOrder) const { ImplAAFTypeDefSP ptd = BaseType(); ASSERTU (ptd); ASSERTU (ptd->IsFixedSize ()); aafUInt32 extElemSize = ptd->PropValSize (); aafUInt32 intElemSize = ptd->ActualSize (); // aafUInt32 intElemSize = ptd->internalSize (0, 0); // aafUInt32 extElemSize = ptd->externalSize (0, 0); aafUInt32 numElems = externalBytesSize / extElemSize; aafInt32 intNumBytesLeft = internalBytesSize; aafInt32 extNumBytesLeft = externalBytesSize; aafUInt32 elem = 0; for (elem = 0; elem < numElems; elem++) { ptd->type()->internalize (externalBytes, extElemSize, internalBytes, intElemSize, byteOrder); internalBytes += intElemSize; externalBytes += extElemSize; intNumBytesLeft -= intElemSize; extNumBytesLeft -= extElemSize; ASSERTU (intNumBytesLeft >= 0); ASSERTU (extNumBytesLeft >= 0); } }
OMUInt32 ImplAAFTypeDefString::internalSize(const OMByte* /*externalBytes*/, OMUInt32 externalBytesSize) const { ImplAAFTypeDefSP ptd = BaseType(); ASSERTU (ptd); ASSERTU (ptd->IsFixedSize ()); aafUInt32 extElemSize = ptd->PropValSize (); aafUInt32 intElemSize = ptd->ActualSize (); // aafUInt32 extElemSize = ptd->externalSize (0, 0); // aafUInt32 intElemSize = ptd->internalSize (0, 0); ASSERTU (intElemSize); aafUInt32 numElems = externalBytesSize / extElemSize; return numElems * intElemSize; }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefString::GetCount ( ImplAAFPropertyValue * pPropVal, aafUInt32 * pCount) { ImplAAFTypeDefSP pIncomingType; ImplAAFTypeDefSP ptd; AAFRESULT hr; if (! pPropVal) return AAFRESULT_NULL_PARAM; if (! pCount) return AAFRESULT_NULL_PARAM; // Get the property value's embedded type and // check if it's the same as the base type. if( AAFRESULT_FAILED( pPropVal->GetType( &pIncomingType ) ) ) return AAFRESULT_BAD_TYPE; ASSERTU (pIncomingType); if( (ImplAAFTypeDef *)pIncomingType != this ) return AAFRESULT_BAD_TYPE; hr = GetType (&ptd); if (AAFRESULT_FAILED(hr)) return hr; ASSERTU (ptd); ASSERTU (ptd->IsFixedSize()); aafUInt32 elemSize = ptd->ActualSize(); aafUInt32 propSize; ASSERTU (pPropVal); ImplAAFPropValDataSP pvd; pvd = dynamic_cast<ImplAAFPropValData *>(pPropVal); ASSERTU (pvd); hr = pvd->GetBitsSize (&propSize); if (AAFRESULT_FAILED(hr)) return hr; ASSERTU (pCount); *pCount = propSize / elemSize; return AAFRESULT_SUCCESS; }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefArray::GetElementValue ( ImplAAFPropertyValue * pInPropVal, aafUInt32 index, ImplAAFPropertyValue ** ppOutPropVal) { if (! pInPropVal) return AAFRESULT_NULL_PARAM; if (! ppOutPropVal) return AAFRESULT_NULL_PARAM; // Get the property value's embedded type and // check if it's the same as the base type. ImplAAFTypeDefSP pIncomingType; if( AAFRESULT_FAILED( pInPropVal->GetType( &pIncomingType ) ) ) return AAFRESULT_BAD_TYPE; ASSERTU (pIncomingType); if( (ImplAAFTypeDef *)pIncomingType != this ) return AAFRESULT_BAD_TYPE; ImplAAFRefArrayValue* pRefArray = dynamic_cast<ImplAAFRefArrayValue*>(pInPropVal); if (NULL != pRefArray) { return pRefArray->GetElementAt(index, ppOutPropVal); } if (index >= pvtCount (pInPropVal)) return AAFRESULT_BADINDEX; aafUInt32 inBitsSize; ImplAAFPropValDataSP pOutPVData; ImplAAFPropValDataSP pvd; ImplAAFTypeDefSP ptd; AAFRESULT hr; hr = GetType (&ptd); if (AAFRESULT_FAILED (hr)) return hr; // aafUInt32 elementSize = ptd->PropValSize(); aafUInt32 elementSize = ptd->ActualSize(); // okay for data not to be registered? ASSERTU (pInPropVal); pvd = dynamic_cast<ImplAAFPropValData*> (pInPropVal); hr = pvd->GetBitsSize (&inBitsSize); if (! AAFRESULT_SUCCEEDED (hr)) return hr; ASSERTU ((index+1) * elementSize <= inBitsSize); pOutPVData = (ImplAAFPropValData *)CreateImpl(CLSID_AAFPropValData); if (! pOutPVData) return AAFRESULT_NOMEMORY; // Bobt: Hack bugfix! SmartPointer operator= will automatically // AddRef; CreateImpl *also* will addref, so we've got one too // many. Put us back to normal. pOutPVData->ReleaseReference (); hr = pOutPVData->Initialize (ptd); if (AAFRESULT_FAILED(hr)) return hr; hr = pOutPVData->AllocateFromPropVal (pvd, index * elementSize, elementSize, NULL); if (AAFRESULT_FAILED(hr)) return hr; ASSERTU (ppOutPropVal); *ppOutPropVal = pOutPVData; ASSERTU (*ppOutPropVal); (*ppOutPropVal)->AcquireReference (); return AAFRESULT_SUCCESS; }