Leaked source code of windows server 2003
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.

193 lines
5.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: psetstg.hxx
  7. //
  8. // Contents: Header for class which provides common implementation of
  9. // IPropertySetStorage.
  10. //
  11. // Classes: CPropertySetStorage
  12. //
  13. // History: 17-Mar-93 BillMo Created.
  14. //
  15. // Notes:
  16. //
  17. //--------------------------------------------------------------------------
  18. #ifndef _PSETSTG_HXX_
  19. #define _PSETSTG_HXX_
  20. #include "h/stgprops.hxx"
  21. #define PROPERTYSETSTORAGE_SIG LONGSIG('P','S','S','T')
  22. #define PROPERTYSETSTORAGE_SIGDEL LONGSIG('P','S','S','t')
  23. #define ENUMSTATPROPSETSTG_SIG LONGSIG('S','P','S','S')
  24. #define ENUMSTATPROPSETSTG_SIGDEL LONGSIG('S','P','S','s')
  25. //+-------------------------------------------------------------------------
  26. //
  27. // Class: CPropertySetStorage
  28. //
  29. // Purpose: Implementation of IPropertySetStorage for native and docfile
  30. // IStorage objects.
  31. //
  32. // Notes:
  33. //
  34. //--------------------------------------------------------------------------
  35. class CPropertySetStorage : public IPropertySetStorage
  36. {
  37. public:
  38. inline CPropertySetStorage(IPrivateStorage *pprivstg);
  39. inline ~CPropertySetStorage();
  40. STDMETHOD(QueryInterface)( REFIID riid, void **ppvObject);
  41. STDMETHOD_(ULONG, AddRef)(void);
  42. STDMETHOD_(ULONG, Release)(void);
  43. STDMETHOD(Create)( REFFMTID rfmtid,
  44. const CLSID * pclsid,
  45. DWORD grfFlags,
  46. DWORD grfMode,
  47. IPropertyStorage ** ppprstg);
  48. STDMETHOD(Open)( REFFMTID rfmtid,
  49. DWORD grfMode,
  50. IPropertyStorage ** ppprstg);
  51. STDMETHOD(Delete)( REFFMTID rfmtid);
  52. STDMETHOD(Enum)( IEnumSTATPROPSETSTG ** ppenum);
  53. private:
  54. inline HRESULT Validate();
  55. private:
  56. ULONG _ulSig;
  57. IPrivateStorage * _pprivstg;
  58. };
  59. //+-------------------------------------------------------------------
  60. //
  61. // Member: CPropertySetStorage::CPropertySetStorage
  62. //
  63. // Synopsis: Initialize the generic property storage object.
  64. //
  65. // Arguments: [pstg]
  66. //
  67. // Notes: The passed [pstg] is saved and then passed into
  68. // the CPropertySet object when it is created on
  69. // Open or Create. Open and Create use it to get a
  70. // matching implementation of mapped stream.
  71. //
  72. // The lifetime of pstg is provided by the fact that
  73. // CPropertySetStorage is a base class of the IStorage.
  74. //
  75. //--------------------------------------------------------------------
  76. CPropertySetStorage::CPropertySetStorage(IPrivateStorage *pprivstg) :
  77. _pprivstg(pprivstg),
  78. _ulSig(PROPERTYSETSTORAGE_SIG)
  79. {
  80. }
  81. //+-------------------------------------------------------------------
  82. //
  83. // Member: CPropertySetStorage::~CPropertySetStorage
  84. //
  85. // Synopsis: Delete the object and set the deletion signature.
  86. //
  87. //--------------------------------------------------------------------
  88. CPropertySetStorage::~CPropertySetStorage()
  89. {
  90. _ulSig = PROPERTYSETSTORAGE_SIGDEL;
  91. }
  92. //+-------------------------------------------------------------------
  93. //
  94. // Member: CPropertySetStorage::Validate
  95. //
  96. // Synopsis: Validate signature.
  97. //
  98. //--------------------------------------------------------------------
  99. inline HRESULT CPropertySetStorage::Validate()
  100. {
  101. return _ulSig == PROPERTYSETSTORAGE_SIG ? S_OK : STG_E_INVALIDHANDLE;
  102. }
  103. //+-------------------------------------------------------------------------
  104. //
  105. // Class: CEnumSTATPROPSETSTG
  106. //
  107. // Purpose: Implementation of IEnumSTATPROPSETSTG for native and docfile
  108. // IStorage objects.
  109. //
  110. // Notes:
  111. //
  112. //--------------------------------------------------------------------------
  113. class CEnumSTATPROPSETSTG : public IEnumSTATPROPSETSTG
  114. {
  115. public:
  116. // for IPropertySetStorage::Enum
  117. CEnumSTATPROPSETSTG(IStorage *pstg, HRESULT *phr);
  118. // for IEnumSTATPROPSETSTG::Clone
  119. CEnumSTATPROPSETSTG(CEnumSTATPROPSETSTG &Other, HRESULT *phr);
  120. ~CEnumSTATPROPSETSTG();
  121. STDMETHOD(QueryInterface)( REFIID riid, void **ppvObject);
  122. STDMETHOD_(ULONG, AddRef)(void);
  123. STDMETHOD_(ULONG, Release)(void);
  124. STDMETHOD(Next)(ULONG celt,
  125. STATPROPSETSTG * rgelt,
  126. ULONG * pceltFetched);
  127. // We don't need RemoteNext.
  128. STDMETHOD(Skip)(ULONG celt);
  129. STDMETHOD(Reset)();
  130. STDMETHOD(Clone)(IEnumSTATPROPSETSTG ** ppenum);
  131. private:
  132. inline HRESULT Validate();
  133. VOID CleanupStatArray();
  134. private:
  135. ULONG _ulSig;
  136. LONG _cRefs;
  137. IEnumSTATSTG * _penumSTATSTG;
  138. STATSTG _statarray[8];
  139. ULONG _cstatTotalInArray;
  140. ULONG _istatNextToRead;
  141. };
  142. //+-------------------------------------------------------------------
  143. //
  144. // Member: CEnumSTATPROPSETSTG::Validate
  145. //
  146. // Synopsis: Validate signature.
  147. //
  148. //--------------------------------------------------------------------
  149. inline HRESULT CEnumSTATPROPSETSTG::Validate()
  150. {
  151. return _ulSig == ENUMSTATPROPSETSTG_SIG ? S_OK : STG_E_INVALIDHANDLE;
  152. }
  153. #endif