Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.0 KiB

  1. #if 0
  2. #if !defined(_FUSION_INC_FUSIONBLOB_H_INCLUDED_)
  3. #define _FUSION_INC_FUSIONBLOB_H_INCLUDED_
  4. #pragma once
  5. template <SIZE_T nInlineBytes> class CFusionGenericBLOB : public BLOB
  6. {
  7. public:
  8. CFusionGenericBLOB() : m_cbBuffer(nInlineBytes)
  9. {
  10. pBlobData = m_rgbInlineBuffer;
  11. cbSize = 0;
  12. }
  13. ~CFusionGenericBLOB()
  14. {
  15. if (pBlobData != m_rgbInlineBuffer)
  16. {
  17. CSxsPreserveLastError ple;
  18. delete []pBlobData;
  19. ple.Restore();
  20. }
  21. }
  22. HRESULT Assign(const BLOB &rblob) { return this->Assign(rblob.pBlobData, rblob.cbSize); }
  23. HRESULT Assign(const BYTE *prgbIn, SIZE_T cbIn)
  24. {
  25. if (cbIn > m_cbBuffer)
  26. {
  27. BYTE *prgbNew = NEW(BYTE[cbIn]);
  28. if (prgbNew == NULL) return E_OUTOFMEMORY;
  29. if (pBlobData != m_rgbInlineBuffer)
  30. delete []pBlobData;
  31. pBlobData = prgbNew;
  32. m_cbBuffer = cbIn;
  33. }
  34. memcpy(pBlobData, prgbIn, cbIn);
  35. cbSize = cbIn;
  36. return NOERROR;
  37. }
  38. HRESULT Append(const BLOB &rblob) { return this->Assign(rblob.pBlobData, rblob.cbSize); }
  39. HRESULT Append(const BYTE *prgbIn, SIZE_T cbIn)
  40. {
  41. SIZE_T cbTotal = cbSize + cbIn;
  42. if (cbTotal > m_cbBuffer)
  43. {
  44. BYTE *prgbNew = NEW(BYTE[cbTotal]);
  45. if (prgbNew == NULL) return E_OUTOFMEMORY;
  46. if (pBlobData != m_rgbInlineBuffer)
  47. delete []pBlobData;
  48. pBlobData = prgbNew;
  49. m_cbBuffer = cbTotal;
  50. }
  51. memcpy(pBlobData, prgbIn, cbIn);
  52. cbSize = cbIn;
  53. return NOERROR;
  54. }
  55. HRESULT Clear()
  56. {
  57. if (pBlobData != m_rgbInlineBuffer)
  58. {
  59. delete []pBlobData;
  60. pBlobData = m_rgbInlineBuffer;
  61. m_cbBuffer = nInlineBytes;
  62. }
  63. cbSize = 0;
  64. return NOERROR;
  65. }
  66. protected:
  67. BYTE m_rgbInlineBuffer[nInlineBytes];
  68. ULONG m_cbBuffer;
  69. };
  70. typedef CFusionGenericBLOB<256> CFusionBLOB;
  71. #endif
  72. #endif