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.

217 lines
5.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1992.
  5. //
  6. // File: ANDCUR.CXX
  7. //
  8. // Contents: And Cursor
  9. //
  10. // Classes: CAndCursor
  11. //
  12. // History: 24-May-91 BartoszM Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <pch.cxx>
  16. #pragma hdrstop
  17. #include "andncur.hxx"
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Member: CAndNotCursor::CAndNotCursor, public
  21. //
  22. // Synopsis: Create a cursor that takes the wids from the first child and
  23. // returns only the ones that do not occur in the second child
  24. //
  25. // Arguments: [pSourceCur] -- the first child cursor
  26. // [pFilterCur] -- the second child cursor
  27. //
  28. // Notes: All cursors must come from the same index
  29. // and the same property
  30. //
  31. // History: 22-Apr-92 AmyA Created
  32. //
  33. //----------------------------------------------------------------------------
  34. CAndNotCursor::CAndNotCursor( XCursor & curSource, XCursor & curFilter )
  35. : _curSource( curSource ),
  36. _curFilter( curFilter )
  37. {
  38. _iid = _curSource->IndexId();
  39. _pid = _curSource->Pid();
  40. _wid = _curSource->WorkId();
  41. FindDisjunction();
  42. END_CONSTRUCTION( CAndNotCursor );
  43. }
  44. //+---------------------------------------------------------------------------
  45. //
  46. // Member: CAndNotCursor::~CAndNotCursor, public
  47. //
  48. // Synopsis: Delete the cursor together with children
  49. //
  50. // History: 22-Apr-92 AmyA Created
  51. //
  52. //----------------------------------------------------------------------------
  53. CAndNotCursor::~CAndNotCursor( )
  54. {
  55. }
  56. //+---------------------------------------------------------------------------
  57. //
  58. // Member: CAndNotCursor::WorkId, public
  59. //
  60. // Synopsis: Get current work id.
  61. //
  62. // History: 22-Apr-92 AmyA Created
  63. //
  64. //----------------------------------------------------------------------------
  65. WORKID CAndNotCursor::WorkId()
  66. {
  67. return _wid;
  68. }
  69. //+---------------------------------------------------------------------------
  70. //
  71. // Member: CAndNotCursor::NextWorkID, public
  72. //
  73. // Synopsis: Move to next work id
  74. //
  75. // Returns: The next work id of the source that is not in the filter.
  76. //
  77. // History: 23-Apr-92 AmyA Created
  78. //
  79. //----------------------------------------------------------------------------
  80. WORKID CAndNotCursor::NextWorkId()
  81. {
  82. _wid = _curSource->NextWorkId();
  83. FindDisjunction();
  84. return _wid;
  85. }
  86. void CAndNotCursor::RatioFinished (ULONG& denom, ULONG& num)
  87. {
  88. _curSource->RatioFinished (denom, num);
  89. }
  90. //+---------------------------------------------------------------------------
  91. //
  92. // Member: CAndNotCursor::HitCount, public
  93. //
  94. // Synopsis: Returns HitCount of the source cursor.
  95. //
  96. // Requires: _wid set to any of the current wid's
  97. //
  98. // Returns: HitCount of the source cursor.
  99. //
  100. // History: 23-Apr-92 AmyA Created
  101. //
  102. //----------------------------------------------------------------------------
  103. ULONG CAndNotCursor::HitCount()
  104. {
  105. return _curSource->HitCount();
  106. }
  107. //+---------------------------------------------------------------------------
  108. //
  109. // Member: CAndNotCursor::Rank, public
  110. //
  111. // Synopsis: Returns Rank of the source cursor.
  112. //
  113. // Requires: _wid set to any of the current wid's
  114. //
  115. // Returns: Rank of the source cursor.
  116. //
  117. // History: 23-Apr-92 AmyA Created
  118. //
  119. //----------------------------------------------------------------------------
  120. LONG CAndNotCursor::Rank()
  121. {
  122. return _curSource->Rank();
  123. }
  124. //+---------------------------------------------------------------------------
  125. //
  126. // Member: CAndNotCursor::FindDisjunction, private
  127. //
  128. // Synopsis: Find the first work id that occurs in the source cursor but
  129. // not in the filter cursor.
  130. //
  131. // Requires: _wid set to any of the current wid's and _widFilter to be set
  132. // to either a wid in _curFilter or widInvalid.
  133. //
  134. // Modifies: [_wid] to point to disjunction or to widInvalid and _widFilter
  135. // to be greater than _wid or to be widInvalid.
  136. //
  137. // History: 23-Apr-92 AmyA Created
  138. //
  139. // Notes: If cursors are in disjunction, no change results
  140. //
  141. //----------------------------------------------------------------------------
  142. void CAndNotCursor::FindDisjunction ()
  143. {
  144. register WORKID widFilter = _curFilter->WorkId();
  145. while ( _wid != widInvalid )
  146. {
  147. while ( widFilter < _wid )
  148. widFilter = _curFilter->NextWorkId();
  149. if ( _wid != widFilter ) // Found a disjunction
  150. return;
  151. _wid = _curSource->NextWorkId(); // the current wid must occur in
  152. // both cursors, so try again.
  153. }
  154. }
  155. //+---------------------------------------------------------------------------
  156. //
  157. // Member: CAndNotCursor::Hit, public
  158. //
  159. // Synopsis: Hits source if filter IsEmpty()
  160. //
  161. // History: 07-Sep-92 MikeHew Created
  162. //
  163. // Notes: Hit() should not be called more than once
  164. //
  165. //----------------------------------------------------------------------------
  166. LONG CAndNotCursor::Hit()
  167. {
  168. if ( _curFilter->IsEmpty() )
  169. {
  170. return _curSource->Hit();
  171. }
  172. else
  173. {
  174. return rankInvalid;
  175. }
  176. }
  177. //+---------------------------------------------------------------------------
  178. //
  179. // Member: CAndNotCursor::NextHit, public
  180. //
  181. // Synopsis: NextHits source
  182. //
  183. // History: 07-Sep-92 MikeHew Created
  184. //
  185. // Notes: NextHit() should not be called either Hit() or NextHit()
  186. // have returned rankInvalid
  187. //
  188. //----------------------------------------------------------------------------
  189. LONG CAndNotCursor::NextHit()
  190. {
  191. return _curSource->NextHit();
  192. }