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.

159 lines
3.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994-1998.
  5. //
  6. // File: InvCur.cxx
  7. //
  8. // Contents: 'Invalid' cursor. Cursor over the pidUnfiltered property
  9. // based on a given widmap.
  10. //
  11. // Classes: CUnfilteredCursor
  12. //
  13. // History: 09-Nov-94 KyleP Created.
  14. //
  15. //----------------------------------------------------------------------------
  16. #include <pch.cxx>
  17. #pragma hdrstop
  18. #include <widtab.hxx>
  19. #include "invcur.hxx"
  20. static const BYTE abUnfiltered[] = { VT_UI1,
  21. (BYTE)(pidUnfiltered >> 24),
  22. (BYTE)(pidUnfiltered >> 16),
  23. (BYTE)(pidUnfiltered >> 8),
  24. (BYTE) pidUnfiltered,
  25. 0,
  26. 1 };
  27. CKeyBuf CUnfilteredCursor::_TheUnfilteredKey( pidUnfiltered, abUnfiltered, sizeof(abUnfiltered) );
  28. int CUnfilteredCursor::CompareAgainstUnfilteredKey( CKey const & key )
  29. {
  30. //
  31. // Compare not available on CKeyBuf
  32. //
  33. return( key.CompareStr( _TheUnfilteredKey ) * -1 );
  34. }
  35. CUnfilteredCursor::CUnfilteredCursor( INDEXID iid, WORKID widMax, CWidTable const & widtab )
  36. : CKeyCursor( iid, widMax ),
  37. _widtab( widtab ),
  38. _iCurrentFakeWid( 0 ),
  39. _occ( 1 ),
  40. _fAtEnd( FALSE ),
  41. _fKeyMoved( FALSE )
  42. {
  43. NextWorkId();
  44. UpdateWeight();
  45. Win4Assert( WorkId() != widInvalid );
  46. }
  47. ULONG CUnfilteredCursor::WorkIdCount()
  48. {
  49. ULONG CUnfiltered = 0;
  50. for ( unsigned i = 1; i <= _widtab.Count(); i++ )
  51. {
  52. if ( !_widtab.IsFiltered(i) && _widtab.IsValid(i) )
  53. CUnfiltered++;
  54. }
  55. return( CUnfiltered );
  56. }
  57. WORKID CUnfilteredCursor::WorkId()
  58. {
  59. if ( _fAtEnd )
  60. return( widInvalid );
  61. else
  62. return( _widtab.FakeWidToUnfilteredWid( _iCurrentFakeWid ) );
  63. }
  64. void CUnfilteredCursor::RatioFinished (ULONG& denom, ULONG& num)
  65. {
  66. denom = _widtab.Count();
  67. num = min (denom, _iCurrentFakeWid);
  68. }
  69. WORKID CUnfilteredCursor::NextWorkId()
  70. {
  71. Win4Assert( !_fKeyMoved);
  72. for ( _iCurrentFakeWid++; _iCurrentFakeWid <= _widtab.Count(); _iCurrentFakeWid++ )
  73. {
  74. if ( !_widtab.IsFiltered(_iCurrentFakeWid) && _widtab.IsValid( _iCurrentFakeWid ) )
  75. break;
  76. }
  77. if ( _iCurrentFakeWid > _widtab.Count() )
  78. {
  79. _fAtEnd = TRUE;
  80. _occ = OCC_INVALID;
  81. }
  82. else
  83. {
  84. Win4Assert( !_fAtEnd );
  85. _occ = 1;
  86. }
  87. return( WorkId() );
  88. }
  89. ULONG CUnfilteredCursor::HitCount()
  90. {
  91. return( 1 );
  92. }
  93. OCCURRENCE CUnfilteredCursor::Occurrence()
  94. {
  95. return( _occ );
  96. }
  97. OCCURRENCE CUnfilteredCursor::NextOccurrence()
  98. {
  99. _occ = OCC_INVALID;
  100. return( _occ );
  101. }
  102. OCCURRENCE CUnfilteredCursor::MaxOccurrence()
  103. {
  104. return 1;
  105. }
  106. ULONG CUnfilteredCursor::OccurrenceCount()
  107. {
  108. Win4Assert( _occ != OCC_INVALID );
  109. return( 1 );
  110. }
  111. CKeyBuf const * CUnfilteredCursor::GetKey()
  112. {
  113. if ( _fKeyMoved )
  114. return( 0 );
  115. else
  116. return( &_TheUnfilteredKey );
  117. }
  118. CKeyBuf const * CUnfilteredCursor::GetNextKey()
  119. {
  120. _fKeyMoved = TRUE;
  121. _fAtEnd = TRUE;
  122. _occ = OCC_INVALID;
  123. return( 0 );
  124. }