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.

135 lines
3.4 KiB

  1. // Stream.h -- Definition for the class CStream
  2. #ifndef __STREAM_H__
  3. #define __STREAM_H__
  4. class CStream : public CITUnknown
  5. {
  6. public:
  7. static HRESULT OpenStream(IUnknown *punkOuter, ILockBytes *pLockBytes,
  8. DWORD grfMode, IStreamITEx **ppStream
  9. );
  10. ~CStream(void);
  11. // IUnknown methods:
  12. private:
  13. CStream(IUnknown *pUnkOuter);
  14. class CImpIStream : public IITStreamITEx
  15. {
  16. public:
  17. CImpIStream(CStream *pBackObj, IUnknown *punkOuter);
  18. ~CImpIStream(void);
  19. HRESULT InitOpenStream(ILockBytes *pLockBytes, DWORD grfMode);
  20. // ISequentialStream methods
  21. /* [local] */ HRESULT __stdcall Read(
  22. /* [out] */ void __RPC_FAR *pv,
  23. /* [in] */ ULONG cb,
  24. /* [out] */ ULONG __RPC_FAR *pcbRead);
  25. /* [local] */ HRESULT __stdcall Write(
  26. /* [size_is][in] */ const void __RPC_FAR *pv,
  27. /* [in] */ ULONG cb,
  28. /* [out] */ ULONG __RPC_FAR *pcbWritten);
  29. // IStream methods:
  30. /* [local] */ HRESULT __stdcall Seek(
  31. /* [in] */ LARGE_INTEGER dlibMove,
  32. /* [in] */ DWORD dwOrigin,
  33. /* [out] */ ULARGE_INTEGER __RPC_FAR *plibNewPosition) ;
  34. HRESULT __stdcall SetSize(
  35. /* [in] */ ULARGE_INTEGER libNewSize);
  36. /* [local] */ HRESULT __stdcall CopyTo(
  37. /* [unique][in] */ IStream __RPC_FAR *pstm,
  38. /* [in] */ ULARGE_INTEGER cb,
  39. /* [out] */ ULARGE_INTEGER __RPC_FAR *pcbRead,
  40. /* [out] */ ULARGE_INTEGER __RPC_FAR *pcbWritten);
  41. HRESULT __stdcall Commit(
  42. /* [in] */ DWORD grfCommitFlags);
  43. HRESULT __stdcall Revert( void);
  44. HRESULT __stdcall LockRegion(
  45. /* [in] */ ULARGE_INTEGER libOffset,
  46. /* [in] */ ULARGE_INTEGER cb,
  47. /* [in] */ DWORD dwLockType);
  48. HRESULT __stdcall UnlockRegion(
  49. /* [in] */ ULARGE_INTEGER libOffset,
  50. /* [in] */ ULARGE_INTEGER cb,
  51. /* [in] */ DWORD dwLockType);
  52. HRESULT __stdcall Stat(
  53. /* [out] */ STATSTG __RPC_FAR *pstatstg,
  54. /* [in] */ DWORD grfStatFlag);
  55. HRESULT __stdcall Clone(
  56. /* [out] */ IStream __RPC_FAR *__RPC_FAR *ppstm);
  57. // IStreamITEx methods:
  58. HRESULT STDMETHODCALLTYPE SetDataSpaceName(const WCHAR * pwcsDataSpaceName);
  59. HRESULT STDMETHODCALLTYPE GetDataSpaceName( WCHAR **ppwcsDataSpaceName);
  60. HRESULT STDMETHODCALLTYPE Flush();
  61. private:
  62. enum { CB_MAX_COPY_SEGMENT = 8192 };
  63. ILockBytes *m_pLockBytes;
  64. CULINT m_ullStreamPosition;
  65. DWORD m_grfMode;
  66. CITCriticalSection m_cs;
  67. };
  68. CImpIStream m_ImpIStream;
  69. };
  70. typedef CStream *PCStream;
  71. extern GUID aIID_CStream[];
  72. extern UINT cInterfaces_CStream;
  73. inline CStream::CStream(IUnknown *pUnkOuter)
  74. : m_ImpIStream(this, pUnkOuter),
  75. CITUnknown(aIID_CStream, cInterfaces_CStream, &m_ImpIStream)
  76. {
  77. }
  78. inline CStream::~CStream(void)
  79. {
  80. }
  81. inline CStream::CImpIStream::CImpIStream(CStream *pBackObj, IUnknown *pUnkOuter)
  82. : IITStreamITEx(pBackObj, pUnkOuter)
  83. {
  84. m_ullStreamPosition = 0;
  85. m_pLockBytes = NULL;
  86. }
  87. inline CStream::CImpIStream::~CImpIStream(void)
  88. {
  89. if (m_pLockBytes)
  90. m_pLockBytes->Release();
  91. }
  92. #endif // __STREAM_H__