⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 old_hxpckts.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//	Purpose://		Everyone usually implements this the same... feel free to use//		this implementation.//STDMETHODIMP_(ULONG32) CHXHeader::Release(){    if (InterlockedDecrement(&m_lRefCount) > 0)    {	return m_lRefCount;    }    delete this;    return 0;}CHXHeader::~CHXHeader(){    CHXMapStringToOb::Iterator i;    // clean up UINT32 properties    for (i = m_ULONG32Map.Begin(); i != m_ULONG32Map.End(); ++i)    {	_CStoreNameUINT32Pair* pnupExpired = (_CStoreNameUINT32Pair*)*i;	delete pnupExpired;    }    m_ULONG32Map.RemoveAll();    // clean up buffer properties    for (i = m_BufferMap.Begin(); i != m_BufferMap.End(); ++i)    {	_CStoreNameBufferPair* pnbpExpired = (_CStoreNameBufferPair*)*i;	delete pnbpExpired;    }    m_BufferMap.RemoveAll();    // clean up string properties    for (i = m_CStringMap.Begin(); i != m_CStringMap.End(); ++i)    {	_CStoreNameBufferPair* pnbpExpired = (_CStoreNameBufferPair*)*i;	delete pnbpExpired;    }    m_CStringMap.RemoveAll();}STDMETHODIMPCHXHeader::SetPropertyULONG32	     (		const char*          pPropertyName,		ULONG32              uPropertyValue){    _CStoreNameUINT32Pair* pnupNew = new _CStoreNameUINT32Pair;    if(!pnupNew)    {        return HXR_OUTOFMEMORY;    }    pnupNew->SetName(pPropertyName);    pnupNew->SetValue(uPropertyValue);    char* pMapString = new_string(pPropertyName);    if(!pMapString)    {        HX_DELETE(pnupNew);        return HXR_OUTOFMEMORY;    }    if(!m_bPreserveCase)    {	strlwr(pMapString);    }    // First make sure there isn't already a property by that name set!    _CStoreNameUINT32Pair* pnupExpired = NULL;    if (m_ULONG32Map.Lookup(pMapString, (void*&)pnupExpired))    {	/* Delete the previously added property */	delete pnupExpired;    }    m_ULONG32Map[pMapString] = (void*)pnupNew;    delete [] pMapString;    return HXR_OK;}STDMETHODIMPCHXHeader::GetPropertyULONG32	     (		const char*          pPropertyName,		REF(ULONG32)         uPropertyValue){    HX_RESULT rc = HXR_OK;    _CStoreNameUINT32Pair* pnupData = NULL;    char* pMapString = new_string(pPropertyName);    if( !pMapString )    {        return HXR_OUTOFMEMORY;    }       if(!m_bPreserveCase)    {	strlwr(pMapString);    }    if (!m_ULONG32Map.Lookup(pMapString, (void*&)pnupData))    {	rc = HXR_FAILED;    }    else    {	uPropertyValue = pnupData->GetValue();    }    delete[] pMapString;    return rc;}STDMETHODIMPCHXHeader::GetFirstPropertyULONG32   (		REF(const char*)     pPropertyName,		REF(ULONG32)         uPropertyValue){	    if ((m_ULONG32Position = m_ULONG32Map.GetStartPosition()) == NULL)	return HXR_FAILED;    _CStoreNameUINT32Pair* pnupData = NULL;    m_ULONG32Map.GetNextAssoc(m_ULONG32Position,                              pPropertyName,                              (void*&)pnupData);    pPropertyName = pnupData->GetName();    uPropertyValue = pnupData->GetValue();    return HXR_OK;}STDMETHODIMPCHXHeader::GetNextPropertyULONG32   (		REF(const char*)    pPropertyName,		REF(ULONG32)        uPropertyValue){	    if (!m_ULONG32Position)	return HXR_FAILED;    _CStoreNameUINT32Pair* pnupData = NULL;    m_ULONG32Map.GetNextAssoc(m_ULONG32Position,                              pPropertyName,                              (void*&)pnupData);    pPropertyName = pnupData->GetName();    uPropertyValue = pnupData->GetValue();    return HXR_OK;}STDMETHODIMPCHXHeader::SetPropertyBuffer	    (		const char*         pPropertyName,		IHXBuffer*         pPropertyValue){    if (!pPropertyValue) return HXR_UNEXPECTED;    _CStoreNameBufferPair* pnbpNew = new _CStoreNameBufferPair;    if(!pnbpNew)    {        return HXR_OUTOFMEMORY;    }    pnbpNew->SetName(pPropertyName);    pnbpNew->SetValue(pPropertyValue);    char* pMapString = new_string(pPropertyName);    if(!pMapString)    {        HX_DELETE(pnbpNew);        return HXR_OUTOFMEMORY;    }    if(!m_bPreserveCase)    {	strlwr(pMapString);    }    // First make sure there isn't already a property by that name set!    _CStoreNameBufferPair* pnbpExpired = NULL;    if (m_BufferMap.Lookup(pMapString, (void*&)pnbpExpired))    {	/* Delete the previously added property */	delete pnbpExpired;    }    m_BufferMap[pMapString] = (void*)pnbpNew;    delete [] pMapString;    return HXR_OK;}STDMETHODIMPCHXHeader::GetPropertyBuffer	    (		const char*         pPropertyName,		REF(IHXBuffer*)    pPropertyValue){    HX_RESULT rc = HXR_OK;    _CStoreNameBufferPair* pnbpData = NULL;    char* pMapString = new_string(pPropertyName);    if(!pMapString)    {        return HXR_OUTOFMEMORY;    }    if(!m_bPreserveCase)    {	strlwr(pMapString);    }    if (!m_BufferMap.Lookup(pMapString, (void*&)pnbpData))    {	rc = HXR_FAILED;    }    else    {	pPropertyValue = pnbpData->GetValue();    }    delete [] pMapString;    return rc;}#if 0STDMETHODIMPCHXHeader::GetEncodedPropertyBuffer(		const char*	    pPropertyName,		REF(IHXBuffer*)    pPropertyValue){    IHXBuffer* pTempPropertyValue;    char* lwr;    lwr = new_string(pPropertyName);    strlwr(lwr);    if (!m_BufferMap.Lookup(lwr, (void*&)pTempPropertyValue))    {	delete [] lwr;	return HXR_FAILED;    }    pPropertyValue = encodeBuffer(pTempPropertyValue);    delete [] lwr;    return HXR_OK;} #endifSTDMETHODIMPCHXHeader::GetFirstPropertyBuffer   (		REF(const char*)    pPropertyName,		REF(IHXBuffer*)    pPropertyValue){	    if ((m_BufferPosition = m_BufferMap.GetStartPosition()) == NULL)	return HXR_FAILED;    _CStoreNameBufferPair* pnbpData = NULL;    m_BufferMap.GetNextAssoc(m_BufferPosition,                             pPropertyName,                             (void*&)pnbpData);    pPropertyName = pnbpData->GetName();    pPropertyValue = pnbpData->GetValue();    return HXR_OK;}STDMETHODIMPCHXHeader::GetNextPropertyBuffer    (		REF(const char*)    pPropertyName,		REF(IHXBuffer*)    pPropertyValue){	    if (!m_BufferPosition)	return HXR_FAILED;    _CStoreNameBufferPair* pnbpData = NULL;    m_BufferMap.GetNextAssoc(m_BufferPosition,                             pPropertyName,                             (void*&)pnbpData);    pPropertyName = pnbpData->GetName();    pPropertyValue = pnbpData->GetValue();    return HXR_OK;}STDMETHODIMPCHXHeader::SetPropertyCString	    (		const char*         pPropertyName,		IHXBuffer*         pPropertyValue){    if (!pPropertyValue) return HXR_UNEXPECTED;    _CStoreNameBufferPair* pnbpNew = new _CStoreNameBufferPair;    if(!pnbpNew)    {        return HXR_OUTOFMEMORY;    }    pnbpNew->SetName(pPropertyName);    pnbpNew->SetValue(pPropertyValue);    char* pMapString = new_string(pPropertyName);    if(!pMapString)    {        HX_DELETE(pnbpNew);        return HXR_OUTOFMEMORY;    }    if(!m_bPreserveCase)    {	strlwr(pMapString);    }    // First make sure there isn't already a property by that name set!    _CStoreNameBufferPair* pnbpExpired = NULL;    if (m_CStringMap.Lookup(pMapString, (void*&)pnbpExpired))    {	/* Delete the previously added property */	delete pnbpExpired;    }    m_CStringMap[pMapString] = (void*)pnbpNew;    delete[] pMapString;    return HXR_OK;}STDMETHODIMPCHXHeader::GetPropertyCString	    (		const char*         pPropertyName,		REF(IHXBuffer*)    pPropertyValue){    HX_RESULT rc = HXR_OK;    _CStoreNameBufferPair* pnbpData = NULL;    char* pMapString = new_string(pPropertyName);    if(!pMapString)    {        return HXR_OUTOFMEMORY;    }    if(!m_bPreserveCase)    {	strlwr(pMapString);    }    if (!m_CStringMap.Lookup(pMapString, (void*&)pnbpData))    {	rc = HXR_FAILED;    }    else    {	pPropertyValue = pnbpData->GetValue();    }    delete[] pMapString;    return rc;}#if 0STDMETHODIMPCHXHeader::GetEncodedPropertyCString (		const char*	    pPropertyName,		REF(IHXBuffer*)    pPropertyValue){    char* lwr;    lwr = new_string(pPropertyName);    strlwr(lwr);    IHXBuffer* pTempPropertyValue;    if (!m_CStringMap.Lookup(lwr, (void*&)pTempPropertyValue))    {	delete[] lwr;	return HXR_FAILED;    }    pPropertyValue = encodeCString(pTempPropertyValue);    delete[] lwr;    return HXR_OK;}#endifSTDMETHODIMPCHXHeader::GetFirstPropertyCString   (		REF(const char*)    pPropertyName,		REF(IHXBuffer*)    pPropertyValue){	    if ((m_CStringPosition = m_CStringMap.GetStartPosition()) == NULL)	return HXR_FAILED;    _CStoreNameBufferPair* pnbpData = NULL;    m_CStringMap.GetNextAssoc(m_CStringPosition,                              pPropertyName,                              (void*&)pnbpData);    pPropertyName = pnbpData->GetName();    pPropertyValue = pnbpData->GetValue();    return HXR_OK;}STDMETHODIMPCHXHeader::GetNextPropertyCString    (		REF(const char*)    pPropertyName,		REF(IHXBuffer*)    pPropertyValue){	    if (!m_CStringPosition)	return HXR_FAILED;    _CStoreNameBufferPair* pnbpData = NULL;    m_CStringMap.GetNextAssoc(m_CStringPosition,                              pPropertyName,                              (void*&)pnbpData);    pPropertyName = pnbpData->GetName();    pPropertyValue = pnbpData->GetValue();    return HXR_OK;}voidCHXHeader::mergeHeaders(    IHXValues* pIHXValuesDestHeaders,     IHXValues* pIHXValuesSourceHeaders){    if(pIHXValuesSourceHeaders && pIHXValuesDestHeaders)    {	// add these headers to the existing ones	//	const char* pPropName = NULL;	UINT32 ulPropValue = 0;	HX_RESULT rc = pIHXValuesSourceHeaders->GetFirstPropertyULONG32	(	    pPropName, 	    ulPropValue	);	while(SUCCEEDED(rc))	{	    pIHXValuesDestHeaders->SetPropertyULONG32	    (		pPropName, 		ulPropValue	    );	    rc = pIHXValuesSourceHeaders->GetNextPropertyULONG32	    (		pPropName, 		ulPropValue	    );	}	IHXBuffer* pBuffer = NULL;	rc = pIHXValuesSourceHeaders->GetFirstPropertyBuffer	(	    pPropName, 	    pBuffer	);	while(SUCCEEDED(rc))	{	    pIHXValuesDestHeaders->SetPropertyBuffer(pPropName, pBuffer);	    pBuffer->Release();	    rc = pIHXValuesSourceHeaders->GetNextPropertyBuffer	    (		pPropName, 		pBuffer	    );	}	rc = pIHXValuesSourceHeaders->GetFirstPropertyCString	(	    pPropName, 	    pBuffer	);	while(SUCCEEDED(rc))	{	    pIHXValuesDestHeaders->SetPropertyCString(pPropName, pBuffer);	    pBuffer->Release();	    rc = pIHXValuesSourceHeaders->GetNextPropertyCString	    (		pPropName, 		pBuffer	    );	}    }}_CStoreName::_CStoreName() : m_strName(){}_CStoreName::~_CStoreName(){}const CHXString& _CStoreName::GetName() const{    return m_strName;}void _CStoreName::SetName(const char* szName){    m_strName = szName;}_CStoreNameUINT32Pair::_CStoreNameUINT32Pair() : m_ulValue(0){}_CStoreNameUINT32Pair::~_CStoreNameUINT32Pair(){}UINT32 _CStoreNameUINT32Pair::GetValue(){    return m_ulValue;}void _CStoreNameUINT32Pair::SetValue(UINT32 ulValue){    m_ulValue = ulValue;}_CStoreNameBufferPair::_CStoreNameBufferPair() : m_pbufValue(NULL){}_CStoreNameBufferPair::~_CStoreNameBufferPair(){    HX_RELEASE(m_pbufValue);}IHXBuffer* _CStoreNameBufferPair::GetValue(){    if(m_pbufValue)    {	m_pbufValue->AddRef();    }    return m_pbufValue;}void _CStoreNameBufferPair::SetValue(IHXBuffer* pbufValue){    HX_RELEASE(m_pbufValue);    m_pbufValue = pbufValue;    if(m_pbufValue)    {	m_pbufValue->AddRef();    }}#if 0IHXBuffer*CHXHeader::encodeBuffer(IHXBuffer* pBuffer){    //XXXBAB - come back to this soon...    CHXBuffer* pEncodedBuffer = new CHXBuffer;    pEncodedBuffer->AddRef();    pEncodedBuffer->Set(pBuffer->GetBuffer(), pBuffer->GetSize());    return pEncodedBuffer;}IHXBuffer*CHXHeader::encodeCString(IHXBuffer* pBuffer){    CHXString tmp;    const char* pStr = (const char*)pBuffer->GetBuffer();    BOOL inEscape = FALSE;    for(size_t i=0;i<strlen(pStr);++i)    {	switch(pStr[i])	{	    case '\n':	    {		tmp += "\\n";	    }	    break;	    case '\t':	    {		tmp += "\\t";	    }	    break;	    case '\r':	    {		tmp += "\\r";	    }	    break;	    case '\"':	    {		tmp += "\\\"";	    }	    break;	    case '\\':	    {		tmp += "\\\\";	    }	    break;	    default:	    {		tmp += pStr[i];	    }	}    }    CHXBuffer* pEncodedBuffer = new CHXBuffer;    pEncodedBuffer->AddRef();    pEncodedBuffer->Set((const BYTE*)(const char*)tmp, tmp.GetLength()+1);    return pEncodedBuffer;}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -