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.

401 lines
11 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: crowset.hxx
  7. //
  8. // Contents: Rowset Class Declaration
  9. //
  10. //--------------------------------------------------------------------------
  11. #ifndef _CROWSET_H_
  12. #define _CROWSET_H_
  13. #define FIRST_ROW 0 // changing this const will require changes to crowset.cxx
  14. #define RESET_ROW -1
  15. #define STD_BMK_SIZE 1
  16. #define ADSI_BMK_SIZE (sizeof(RBOOKMARK))
  17. typedef struct tagCOLDATA
  18. {
  19. DWORD dwColOffset; // offset of column within row buffer
  20. DBTYPE wType; // OLEDB type of column
  21. } COLDATA;
  22. typedef struct tagROWBUFFER // header preceding all columns in a row
  23. {
  24. LONG lRefCount; // reference count of row
  25. LONG lRow; // row #
  26. DWORD cColErrors; // #columns in error in the row
  27. // ADS_SEARCH_COLUMN of the ADsPath attribute. Used only if
  28. // m_fadsPathPresent is FALSE
  29. ADS_SEARCH_COLUMN adsSearchCol;
  30. } ROWBUFFER;
  31. typedef struct tagOLEDBDATA
  32. {
  33. // Stores the ADS_SEARCH_COLUMN of this attribute so that it can be freed
  34. // later.
  35. ADS_SEARCH_COLUMN adsSearchCol;
  36. DBSTATUS dbStatus;
  37. DWORD dwLength;
  38. char *OledbValue; // Should be the last field in this structure
  39. } OLEDBDATA;
  40. typedef LONG RBOOKMARK;
  41. typedef enum tagFETCHDIR
  42. {
  43. FORWARD,
  44. BACKWARD
  45. } FETCHDIR;
  46. class CRowset : public IAccessor,
  47. public IColumnsInfo,
  48. public IConvertType,
  49. #if (!defined(BUILD_FOR_NT40))
  50. public IGetRow,
  51. #endif
  52. public IRowsetIdentity,
  53. public IRowsetInfo,
  54. public IRowsetScroll
  55. {
  56. friend class CRowProvider;
  57. friend class CRow;
  58. protected:
  59. CRowsetInfo *m_pCRowsetInfo;
  60. CImpIAccessor *m_pCAccessor;
  61. CRowProvider *m_pCRowProvider;
  62. CUtilProp *m_pCUtilProp;
  63. IDataConvert *m_pIDataConvert;
  64. IColumnsInfo *m_pIColumnsInfo;
  65. IRowProvider *m_pIRowProvider;
  66. IMalloc *m_pIMalloc;
  67. LONG m_lLastFetchRow;
  68. DWORD m_cRowBytes;
  69. DBORDINAL m_cCol;
  70. COLDATA *m_pColData;
  71. CRITICAL_SECTION m_RowsetCritSection;
  72. BOOL m_fCritSectionInitialized;
  73. BOOL m_fEndOfRowset;
  74. BOOL m_fadsPathPresent;
  75. BOOL m_fAllAttrs;
  76. LONG m_cNumRowsCached;
  77. FETCHDIR m_LastFetchDir;
  78. ROWBUFFER **m_pRowsPtr;
  79. DWORD m_dwRowCacheSize;
  80. LONG m_lCurrentRow;
  81. DWORD m_dwMaxCacheSize;
  82. DWORD m_cRef;
  83. // Methods
  84. HRESULT CopyAccessors(
  85. ULONG cAccessors, // accessor count
  86. CCommandObject *pCCommand, // Command Object
  87. HACCESSOR rgAccessors[] // accessors on command object
  88. );
  89. HRESULT GetColOffsets(void);
  90. HRESULT BringInRow(void);
  91. inline DWORD ColumnAlign(DWORD dwValue)
  92. {
  93. // align to next higher 8 byte boundary
  94. return ((dwValue+7) & (~7));
  95. }
  96. HRESULT BmkToRow(
  97. ULONG cbBookmark, // number of bytes in the bookmark
  98. const BYTE *pBookmark, // pointer to bookmark
  99. LONG *plRow
  100. );
  101. HRESULT SeekToRow(LONG lTargetRow);
  102. HRESULT SeekToEnd(void);
  103. inline RBOOKMARK RowToBmk(LONG lRow)
  104. {
  105. // bookmark is the same as the row
  106. return (RBOOKMARK) lRow;
  107. }
  108. inline LONG HROWToRow(HROW hRow)
  109. {
  110. // row handle is same as row + 1
  111. return ((LONG) hRow) - 1;
  112. }
  113. inline HROW RowToHROW(LONG lRow)
  114. {
  115. // row handle is same as row + 1
  116. return (HROW) (lRow + 1);
  117. }
  118. inline LONG HROWToIndex(HROW hRow)
  119. {
  120. int i;
  121. ROWBUFFER *pRowBuffer;
  122. for(i = 0; i < m_cNumRowsCached; i++)
  123. {
  124. pRowBuffer = m_pRowsPtr[i];
  125. ADsAssert(pRowBuffer);
  126. if( pRowBuffer->lRow == (HROWToRow(hRow)) )
  127. return i;
  128. }
  129. return -1; // invalid index
  130. }
  131. HRESULT GetMaxCacheSize(void);
  132. HRESULT IsRowObjRequested(BOOL *pfRowObjRequested);
  133. inline LONG RefCount(ROWBUFFER *pRowBuffer)
  134. {
  135. return pRowBuffer->lRefCount;
  136. }
  137. inline LONG IncrRefCount(ROWBUFFER *pRowBuffer)
  138. {
  139. return pRowBuffer->lRefCount++;
  140. }
  141. inline LONG DecrRefCount(ROWBUFFER *pRowBuffer)
  142. {
  143. return pRowBuffer->lRefCount--;
  144. }
  145. inline LONG Max(LONG x, LONG y)
  146. {
  147. return (x > y) ? x : y;
  148. }
  149. inline LONG Min(ULONG_PTR x, ULONG_PTR y)
  150. {
  151. return (x > y) ? y : x;
  152. }
  153. void FreeRow(ROWBUFFER *pRowBuffer);
  154. HRESULT GetADsPathFromHROW(HROW hRow, ADS_CASE_IGNORE_STRING *padsPath);
  155. public:
  156. CRowset(void);
  157. ~CRowset(void);
  158. static
  159. HRESULT CreateRowset(
  160. CRowProvider *pIRowProvider, // The Row provider
  161. IUnknown *pParentObj, // parent object, a command or a session
  162. CSessionObject *pCSession, // Session Object
  163. CCommandObject *pCCommand, // Command Object
  164. ULONG cPropertySets, // #prop sets in rowset property group
  165. DBPROPSET rgPropertySets[],// properties in rowset property group
  166. ULONG cAccessors, // accessor count
  167. HACCESSOR rgAccessors[], // accessors on command object
  168. BOOL fadsPathPresent, // Is ADsPath present in query
  169. BOOL fAllAttrs, // Return all attrs from row object?
  170. REFIID riid, // Interface desired
  171. IUnknown **ppIRowset // pointer to desired interface
  172. );
  173. STDMETHODIMP FInit(
  174. CRowProvider *pIRowProvider, // The Row provider
  175. IUnknown *pParentObj, // parent object, a command or a session
  176. CSessionObject *pCSession, // Session Object
  177. CCommandObject *pCCommand, // Command Object
  178. ULONG cPropertySets, // #prop sets in rowset property group
  179. DBPROPSET rgPropertySets[],// properties in rowset property group
  180. ULONG cAccessors, // accessor count
  181. HACCESSOR rgAccessors[], // accessors on command object
  182. BOOL fadsPathPresent, // Is ADsPath present in query
  183. BOOL fAllAttrs // Return all attrs from row object?
  184. );
  185. STDMETHODIMP GetNextRows(
  186. HCHAPTER hChapter, // ignored since this is not a chaptered rowset
  187. DBROWOFFSET lRowsOffset,
  188. DBROWCOUNT cRows,
  189. DBCOUNTITEM *pcRowsObtained,
  190. HROW **prghRows
  191. );
  192. STDMETHODIMP GetRowsAt(
  193. HWATCHREGION hReserved, // Reserved for future use. Ignored.
  194. HCHAPTER hChapter, // ignored as this is not a chaptered rowset
  195. DBBKMARK cbBookmark,
  196. const BYTE *pBookmark,
  197. DBROWOFFSET lRowsOffset,
  198. DBROWCOUNT cRows,
  199. DBCOUNTITEM *pcRowsObtained,
  200. HROW **prghRows
  201. );
  202. STDMETHODIMP GetData(
  203. HROW hRow,
  204. HACCESSOR hAccessor,
  205. void *pData
  206. );
  207. STDMETHODIMP AddRefRows(
  208. DBCOUNTITEM cRows,
  209. const HROW rghRows[],
  210. ULONG rgRefCounts[],
  211. DBROWSTATUS rgRowStatus[]
  212. );
  213. STDMETHODIMP ReleaseRows(
  214. DBCOUNTITEM cRows,
  215. const HROW rghRows[],
  216. DBROWOPTIONS rgRowOptions[], // ignored
  217. ULONG rgRefCounts[],
  218. DBROWSTATUS rgRowStatus[]
  219. );
  220. STDMETHODIMP RestartPosition(HCHAPTER hChapter);
  221. STDMETHODIMP QueryInterface(THIS_ REFIID riid, LPVOID FAR* ppvObj);
  222. STDMETHODIMP_(ULONG) AddRef(void);
  223. STDMETHODIMP_(ULONG) Release(void);
  224. STDMETHODIMP AddRefAccessor(HACCESSOR hAccessor, DBREFCOUNT *pcRefCount);
  225. STDMETHODIMP CreateAccessor(
  226. DBACCESSORFLAGS dwAccessorFlags,
  227. DBCOUNTITEM cBindings,
  228. const DBBINDING rgBindings[],
  229. DBLENGTH cbRowSize,
  230. HACCESSOR * phAccessor,
  231. DBBINDSTATUS rgStatus[]
  232. );
  233. STDMETHODIMP ReleaseAccessor(HACCESSOR hAccessor, DBREFCOUNT *pcRefCount);
  234. STDMETHODIMP GetBindings(
  235. HACCESSOR hAccessor,
  236. DBACCESSORFLAGS * pdwAccessorFlags,
  237. DBCOUNTITEM * pcBindings,
  238. DBBINDING ** prgBindings
  239. );
  240. STDMETHODIMP GetColumnInfo(
  241. DBORDINAL *pcColumns,
  242. DBCOLUMNINFO **pprgInfo,
  243. WCHAR ** ppStringsBuffer
  244. );
  245. STDMETHODIMP MapColumnIDs(
  246. DBORDINAL cColumnIDs,
  247. const DBID rgColumnIDs[],
  248. DBORDINAL rgColumns[]
  249. );
  250. STDMETHODIMP CanConvert(
  251. DBTYPE wFromType,
  252. DBTYPE wToType,
  253. DBCONVERTFLAGS dwConvertFlags
  254. );
  255. STDMETHODIMP GetRowFromHROW(
  256. IUnknown *pUnkOuter,
  257. HROW hRow,
  258. REFIID riid,
  259. IUnknown **ppUnk
  260. );
  261. STDMETHODIMP GetURLFromHROW(
  262. HROW hRow,
  263. LPOLESTR *ppwszURL
  264. );
  265. STDMETHODIMP IsSameRow(
  266. HROW hRow1,
  267. HROW hRow2
  268. );
  269. STDMETHODIMP GetProperties(
  270. const ULONG cPropertyIDSets,
  271. const DBPROPIDSET rgPropertyIDSets[],
  272. ULONG *pcPropertySets,
  273. DBPROPSET **prgPropertySets
  274. );
  275. STDMETHODIMP GetReferencedRowset(
  276. DBORDINAL iOrdinal,
  277. REFIID riid,
  278. IUnknown **ppReferencedRowset
  279. );
  280. STDMETHODIMP GetSpecification(
  281. REFIID riid,
  282. IUnknown **ppSpecification
  283. );
  284. STDMETHODIMP Compare(
  285. HCHAPTER hChapter,
  286. DBBKMARK cbBookmark1,
  287. const BYTE *pBookmark1,
  288. DBBKMARK cbBookmark2,
  289. const BYTE *pBookmark2,
  290. DBCOMPARE *pComparison
  291. );
  292. STDMETHODIMP Hash(
  293. HCHAPTER hChapter,
  294. DBBKMARK cBookmarks,
  295. const DBBKMARK rgcbBookmarks[],
  296. const BYTE *rgpBookmarks[],
  297. DBHASHVALUE rgHashedValues[],
  298. DBROWSTATUS rgBookmarkStatus[]
  299. );
  300. STDMETHODIMP GetRowsByBookmark(
  301. HCHAPTER hChapter,
  302. DBCOUNTITEM cRows,
  303. const DBBKMARK rgcbBookmarks[],
  304. const BYTE *rgpBookmarks[],
  305. HROW rghRows[],
  306. DBROWSTATUS rgRowStatus[]
  307. );
  308. STDMETHODIMP GetApproximatePosition(
  309. HCHAPTER hChapter,
  310. DBBKMARK cbBookmark,
  311. const BYTE *pBookmark,
  312. DBCOUNTITEM *pulPosition,
  313. DBCOUNTITEM *pcRows
  314. );
  315. STDMETHODIMP GetRowsAtRatio(
  316. HWATCHREGION hReserved1,
  317. HCHAPTER hChapter,
  318. DBCOUNTITEM ulNumerator,
  319. DBCOUNTITEM ulDenominator,
  320. DBROWCOUNT cRows,
  321. DBCOUNTITEM *pcRowsObtained,
  322. HROW **prghRows
  323. );
  324. };
  325. #endif // _CROWSET_H_