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.

213 lines
5.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: simpstm.hxx
  7. //
  8. // Contents: CSimpStream class
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 04-Aug-94 PhilipLa Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef __SIMPSTM_HXX__
  18. #define __SIMPSTM_HXX__
  19. //+---------------------------------------------------------------------------
  20. //
  21. // Class: CSimpStream
  22. //
  23. // Purpose:
  24. //
  25. // Interface:
  26. //
  27. // History: 04-Aug-94 PhilipLa Created
  28. //
  29. // Notes:
  30. //
  31. //----------------------------------------------------------------------------
  32. interface CSimpStream: public IStream, public IMarshal
  33. {
  34. public:
  35. inline CSimpStream();
  36. inline ~CSimpStream();
  37. SCODE Init(CSimpStorage *pstgParent, HANDLE hFile, ULONG ulSeekStart);
  38. // From IUnknown
  39. STDMETHOD(QueryInterface)(REFIID iid, void **ppvObj);
  40. STDMETHOD_(ULONG,AddRef)(void);
  41. STDMETHOD_(ULONG,Release)(void);
  42. // New methods
  43. STDMETHOD(Read)(VOID HUGEP *pv,
  44. ULONG cb,
  45. ULONG *pcbRead);
  46. STDMETHOD(Write)(VOID const HUGEP *pv,
  47. ULONG cb,
  48. ULONG *pcbWritten);
  49. STDMETHOD(Seek)(LARGE_INTEGER dlibMove,
  50. DWORD dwOrigin,
  51. ULARGE_INTEGER *plibNewPosition);
  52. STDMETHOD(SetSize)(ULARGE_INTEGER cb);
  53. STDMETHOD(CopyTo)(IStream *pstm,
  54. ULARGE_INTEGER cb,
  55. ULARGE_INTEGER *pcbRead,
  56. ULARGE_INTEGER *pcbWritten);
  57. STDMETHOD(Commit)(DWORD grfCommitFlags);
  58. STDMETHOD(Revert)(void);
  59. STDMETHOD(LockRegion)(ULARGE_INTEGER libOffset,
  60. ULARGE_INTEGER cb,
  61. DWORD dwLockType);
  62. STDMETHOD(UnlockRegion)(ULARGE_INTEGER libOffset,
  63. ULARGE_INTEGER cb,
  64. DWORD dwLockType);
  65. STDMETHOD(Stat)(STATSTG *pstatstg, DWORD grfStatFlag);
  66. STDMETHOD(Clone)(IStream **ppstm);
  67. // IMarshal
  68. STDMETHOD(GetUnmarshalClass)(REFIID riid,
  69. LPVOID pv,
  70. DWORD dwDestContext,
  71. LPVOID pvDestContext,
  72. DWORD mshlflags,
  73. LPCLSID pCid);
  74. STDMETHOD(GetMarshalSizeMax)(REFIID riid,
  75. LPVOID pv,
  76. DWORD dwDestContext,
  77. LPVOID pvDestContext,
  78. DWORD mshlflags,
  79. LPDWORD pSize);
  80. STDMETHOD(MarshalInterface)(IStream *pStm,
  81. REFIID riid,
  82. LPVOID pv,
  83. DWORD dwDestContext,
  84. LPVOID pvDestContext,
  85. DWORD mshlflags);
  86. STDMETHOD(UnmarshalInterface)(IStream *pStm,
  87. REFIID riid,
  88. LPVOID *ppv);
  89. STDMETHOD(ReleaseMarshalData)(IStream *pStm);
  90. STDMETHOD(DisconnectObject)(DWORD dwReserved);
  91. protected:
  92. LONG _cReferences;
  93. LONG _ulSeekStart;
  94. ULONG _ulSeekPos;
  95. #ifdef SECURE_SIMPLE_MODE
  96. ULONG _ulHighWater;
  97. #if DBG == 1
  98. void CheckSeekPointer(void);
  99. #endif // DBG
  100. #endif // SECURE_SIMPLE_MODE
  101. CSimpStorage *_pstgParent;
  102. HANDLE _hFile;
  103. };
  104. //+---------------------------------------------------------------------------
  105. //
  106. // Member: CSimpStream::CSimpStream, public
  107. //
  108. // Synopsis: Constructor
  109. //
  110. // History: 04-Aug-94 PhilipLa Created
  111. //
  112. //----------------------------------------------------------------------------
  113. inline CSimpStream::CSimpStream()
  114. {
  115. _cReferences = 0;
  116. _ulSeekStart = 0;
  117. _pstgParent = NULL;
  118. _hFile = NULL;
  119. }
  120. //+---------------------------------------------------------------------------
  121. //
  122. // Member: CSimpStream::~CSimpStream, public
  123. //
  124. // Synopsis: Destructor
  125. //
  126. // History: 04-Aug-94 PhilipLa Created
  127. //
  128. //----------------------------------------------------------------------------
  129. inline CSimpStream::~CSimpStream()
  130. {
  131. }
  132. //+---------------------------------------------------------------------------
  133. //
  134. // Class: CSimpStreamOpen
  135. //
  136. // Purpose: simple stream class for simple mode read
  137. //
  138. // Interface: IStream
  139. //
  140. // History: 04-Jun-96 HenryLee Created
  141. //
  142. // Notes: does not check for reverted state if parent storage is closed
  143. //
  144. //----------------------------------------------------------------------------
  145. class CSimpStreamOpen : public CSimpStream
  146. {
  147. public:
  148. inline CSimpStreamOpen();
  149. inline ~CSimpStreamOpen();
  150. SCODE Init(CSimpStorageOpen *pstgParent, HANDLE hFile,
  151. ULONG ulSeekStart, DWORD grfMode, CDfNameList *pdfl);
  152. STDMETHOD_(ULONG, Release)(void);
  153. STDMETHOD(Read)(VOID *pv, ULONG cb, ULONG *pcbRead);
  154. STDMETHOD(Write)(VOID const *pv, ULONG cb, ULONG *pcbWritten);
  155. STDMETHOD(SetSize)(ULARGE_INTEGER cb);
  156. STDMETHOD(Seek)(LARGE_INTEGER libMove, DWORD dwOrigin,
  157. ULARGE_INTEGER *plibNewPosition);
  158. STDMETHOD(Stat)(STATSTG *pstatstg, DWORD grfStatFlag);
  159. private:
  160. CDfNameList * _pdfl; // back pointer to storage's name list element
  161. DWORD _grfMode; // open mode to check for write access
  162. };
  163. //+---------------------------------------------------------------------------
  164. //
  165. // Member: CSimpStreamOpen::CSimpStreamOpen, public
  166. //
  167. // Synopsis: Constructor
  168. //
  169. // History: 04-May-96 HenryLee Created
  170. //
  171. //----------------------------------------------------------------------------
  172. inline CSimpStreamOpen::CSimpStreamOpen() : _pdfl(NULL)
  173. {
  174. }
  175. //+---------------------------------------------------------------------------
  176. //
  177. // Member: CSimpStreamOpen::~CSimpStreamOpen, public
  178. //
  179. // Synopsis: Destructor
  180. //
  181. // History: 04-May-96 HenryLee Created
  182. //
  183. //----------------------------------------------------------------------------
  184. inline CSimpStreamOpen::~CSimpStreamOpen()
  185. {
  186. }
  187. #endif // #ifndef __SIMPSTM_HXX__