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.

110 lines
2.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995.
  5. //
  6. // File: RowCache.cxx
  7. //
  8. // Contents: Forward-only cache
  9. //
  10. // Classes: CMiniRowCache
  11. //
  12. // History: 05-Jun-95 KyleP Created
  13. // 14-JAN-97 KrishnaN Undefined CI_INETSRV and related changes
  14. //
  15. //----------------------------------------------------------------------------
  16. #include <pch.cxx>
  17. #pragma hdrstop
  18. #include "rowcache.hxx"
  19. //+---------------------------------------------------------------------------
  20. //
  21. // Member: CMiniRowCache::CMiniRowCache, public
  22. //
  23. // Synopsis: Initialize
  24. //
  25. // Arguments: [Index] -- Identifier. Not used internally.
  26. // [pRowset] -- Rowset used to fill cache.
  27. // [cBindings] -- Size of [pBindings].
  28. // [pBindings] -- Default binding.
  29. // [cbMaxLen] -- Max length of data fetched via [pBindings]
  30. //
  31. // History: 05-Jun-95 KyleP Created.
  32. //
  33. //----------------------------------------------------------------------------
  34. CMiniRowCache::CMiniRowCache( int Index,
  35. IRowset * pRowset,
  36. unsigned cBindings,
  37. DBBINDING * pBindings,
  38. unsigned cbMaxLen )
  39. : PMiniRowCache( Index, pRowset, cBindings, pBindings, cbMaxLen )
  40. {
  41. Next();
  42. END_CONSTRUCTION( CMiniRowCache );
  43. }
  44. //+---------------------------------------------------------------------------
  45. //
  46. // Member: CMiniPositionableCache::Next, public
  47. //
  48. // Synopsis: Moves to next row
  49. //
  50. // Returns: Move status
  51. //
  52. // History: 05-Jun-95 KyleP Created.
  53. //
  54. //----------------------------------------------------------------------------
  55. PMiniRowCache::ENext CMiniRowCache::Next( int iDir /* = 1 */ )
  56. {
  57. // Cna only go forward here
  58. Win4Assert( iDir > 0 );
  59. //
  60. // If we had a row in cache, Just advance to it. Otherwise
  61. // fetch more rows from table.
  62. //
  63. _ihrow++;
  64. if ( _ihrow >= _chrow )
  65. {
  66. //
  67. // Fetch more rows from table.
  68. //
  69. HROW * phrow = _ahrow.GetPointer();
  70. SCODE sc = _pRowset->GetNextRows( 0, 0, _ahrow.Count() , &_chrow, &phrow );
  71. vqDebugOut(( DEB_ITRACE, "Fetched %d from %d\n", _chrow, _Index ));
  72. if ( FAILED(sc) )
  73. {
  74. vqDebugOut(( DEB_ERROR, "CMiniRowCache: Error 0x%x from GetNextRows\n", sc ));
  75. _chrow = 0;
  76. THROW( CException( sc ) );
  77. }
  78. else if ( 0 == _chrow && sc != DB_S_ENDOFROWSET )
  79. {
  80. return( CMiniRowCache::NotNow );
  81. }
  82. _ihrow = 0;
  83. }
  84. if( IsAtEnd() )
  85. {
  86. return CMiniRowCache::EndOfRows;
  87. }
  88. LoadData();
  89. return CMiniRowCache::Ok;
  90. }