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.

185 lines
5.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 2000.
  5. //
  6. // File: wqiter.hxx
  7. //
  8. // Contents: WEB Query iter class
  9. //
  10. // History: 96/Jan/3 DwightKr Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #pragma once
  14. class CWQueryItem;
  15. class COutputFormat;
  16. const ULONG ITER_CACHE_SIZE = 20; // A guess at the avg max # rows per page
  17. const ULONG NUMBER_INLINE_COLS = 10;// Number of output columns to buffer
  18. // in-line. If cCols > 10, then we'll
  19. // have to allocate a buffer
  20. //+---------------------------------------------------------------------------
  21. //
  22. // Class: COutputColumn
  23. //
  24. // Purpose: The results of a single output column from an OLEDB query.
  25. //
  26. // History: 96/Jan/23 DwightKr Created
  27. //
  28. //----------------------------------------------------------------------------
  29. class COutputColumn
  30. {
  31. public:
  32. PROPVARIANT * GetVariant() { return _pVariant; }
  33. private:
  34. PROPVARIANT * _pVariant;
  35. };
  36. //+---------------------------------------------------------------------------
  37. //
  38. // Class CBaseQueryResultsIter - protocol class; all query result iterators
  39. // must inherit from this class
  40. //
  41. //----------------------------------------------------------------------------
  42. class CBaseQueryResultsIter
  43. {
  44. public:
  45. CBaseQueryResultsIter( CWQueryItem & item,
  46. HACCESSOR hAccessor,
  47. ULONG cCols );
  48. virtual ~CBaseQueryResultsIter();
  49. virtual void Init( CVariableSet & VariableSet, COutputFormat & outputFormat ) = 0;
  50. virtual void Next() = 0;
  51. virtual COutputColumn * GetRowData() = 0;
  52. BOOL AtEnd() { return _lRecordsToRetrieve == 0 &&
  53. _iCurrentCachedRow == _cRowsReturnedToCache; }
  54. LONG GetNextRecordNumber() const { return _lNextRecordNumber; }
  55. LONG GetFirstRecordNumber() const { return _lFirstRecordNumber; }
  56. LONG GetMaxRecordsPerPage() const { return _lMaxRecordsPerPage; }
  57. CVariableSet & GetVariableSet() const { return *_pVariableSet; }
  58. ULONG GetColumnCount() const { return _cColumns; }
  59. protected:
  60. void InitializeLocalVariables( CVariableSet & variableSet,
  61. COutputFormat & outputFormat );
  62. HROW _ahCachedRows[ITER_CACHE_SIZE]; // cached rows
  63. DBCOUNTITEM _cRowsReturnedToCache; // # rows in cache
  64. ULONG _iCurrentCachedRow; // current row in cache
  65. CWQueryItem & _item; // Query item we're iterating over
  66. COutputColumn * _pOutputColumns; // ptr to output columns
  67. COutputColumn _aOutputColumns[NUMBER_INLINE_COLS];
  68. HACCESSOR _hAccessor; // Accessor to query results
  69. LONG _cColumns; // # columns in query results
  70. LONG _lFirstRecordNumber; // # of first record available
  71. LONG _lNextRecordNumber; // # of next record available
  72. LONG _lMaxRecordsPerPage; // Max # records per page
  73. LONG _lRecordsToRetrieve; // # records remaining to read
  74. DBROWCOUNT _lTotalMatchedRecords; // # of records matching query
  75. CVariableSet * _pVariableSet; // Our replaceable parameters
  76. };
  77. //+---------------------------------------------------------------------------
  78. //
  79. // Class: CQueryResultsIter
  80. //
  81. // Purpose: A non-sequential iterator over a CQueryItem's query results
  82. //
  83. // History: 96/Jan/23 DwightKr Created
  84. //
  85. //----------------------------------------------------------------------------
  86. class CQueryResultsIter : public CBaseQueryResultsIter
  87. {
  88. INLINE_UNWIND(CQueryResultsIter)
  89. public:
  90. CQueryResultsIter( CWQueryItem & item,
  91. IRowsetScroll * pRowsetScroll,
  92. HACCESSOR hAccessor,
  93. ULONG cCols );
  94. ~CQueryResultsIter();
  95. void Init( CVariableSet & VariableSet, COutputFormat & outputFormat );
  96. void Next();
  97. COutputColumn * GetRowData();
  98. private:
  99. void FillRowsetCache();
  100. void ReleaseRowsetCache();
  101. void InitializeLocalVariables( CVariableSet & variableSet,
  102. COutputFormat & outputFormat );
  103. IRowsetScroll * _pIRowsetScroll; // Rowset interface
  104. };
  105. //+---------------------------------------------------------------------------
  106. //
  107. // Class: CSeqQueryResultsIter
  108. //
  109. // Purpose: A sequential iterator over a CQueryItem's query results
  110. //
  111. // History: 96/Jan/23 DwightKr Created
  112. //
  113. //----------------------------------------------------------------------------
  114. class CSeqQueryResultsIter : public CBaseQueryResultsIter
  115. {
  116. INLINE_UNWIND(CSeqQueryResultsIter)
  117. public:
  118. CSeqQueryResultsIter( CWQueryItem & item,
  119. IRowset * pRowset,
  120. HACCESSOR hAccessor,
  121. ULONG cCols,
  122. ULONG ulNextRecordNumber );
  123. ~CSeqQueryResultsIter();
  124. void Init( CVariableSet & VariableSet, COutputFormat & outputFormat );
  125. void Next();
  126. COutputColumn * GetRowData();
  127. private:
  128. void FillRowsetCache( ULONG cRowsToSkip );
  129. void ReleaseRowsetCache();
  130. void InitializeLocalVariables( CVariableSet & variableSet,
  131. COutputFormat & outputFormat );
  132. IRowset * _pIRowset;
  133. };
  134. void SetCGIVariables( CVariableSet & variableSet, CWebServer & webServer );