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.

168 lines
4.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1998
  5. //
  6. // File: isearch.hxx
  7. //
  8. // Contents: CSearch
  9. //
  10. // History: 23-Dec-1994 BartoszM Created
  11. //
  12. //--------------------------------------------------------------------------
  13. #pragma once
  14. #include <spropmap.hxx>
  15. #include <pidmap.hxx>
  16. #include <pidcvt.hxx>
  17. #include <lang.hxx>
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Class: CHitSink
  21. //
  22. // Purpose: A repository of filter regions that comprise a single hit
  23. //
  24. // History: 10-Oct-94 BartoszM Created
  25. //
  26. //----------------------------------------------------------------------------
  27. class CHitSink
  28. {
  29. public:
  30. CHitSink () : _nFound(0), _aRegion(1) {}
  31. void Reset () { _nFound = 0; }
  32. void AddPosition ( const FILTERREGION& region );
  33. int Count () const { return _nFound; }
  34. const FILTERREGION& GetRegion (unsigned i) const { return _aRegion.Get(i); }
  35. private:
  36. unsigned _nFound;
  37. CDynArrayInPlace<FILTERREGION> _aRegion;
  38. };
  39. //+---------------------------------------------------------------------------
  40. //
  41. // Class: CSearchHit
  42. //
  43. // Purpose: Combines rank and an array of filter regions comprising a hit
  44. //
  45. // History: 15-Sep-94 BartoszM Created
  46. //
  47. //----------------------------------------------------------------------------
  48. class CTextSource;
  49. class CSearchHit
  50. {
  51. public:
  52. CSearchHit ( LONG rank, unsigned count, FILTERREGION* aRegion )
  53. : _rank (rank), _count(count), _aRegion(aRegion)
  54. {}
  55. ~CSearchHit ()
  56. {
  57. if (_aRegion)
  58. CoTaskMemFree (_aRegion);
  59. }
  60. LONG Rank () const { return _rank; }
  61. unsigned Count () const { return _count; }
  62. FILTERREGION* AcqHit ()
  63. {
  64. FILTERREGION* tmp = _aRegion;
  65. _aRegion = 0;
  66. return tmp;
  67. }
  68. const FILTERREGION& FirstRegion () const
  69. {
  70. return _aRegion[0];
  71. }
  72. private:
  73. LONG _rank;
  74. unsigned _count;
  75. FILTERREGION* _aRegion;
  76. };
  77. DECL_DYNSTACK ( CHitArray, CSearchHit );
  78. //+---------------------------------------------------------------------------
  79. //
  80. // Class: CSearch
  81. //
  82. // Purpose: Text searching using IFilter
  83. //
  84. // History: 15-Sep-94 BartoszM Created
  85. //
  86. //----------------------------------------------------------------------------
  87. extern "C" GUID CLSID_CSearch;
  88. class CDbRestriction;
  89. class CSearchKeyRepository;
  90. class CCursor;
  91. class CSearch : public ISearchQueryHits
  92. {
  93. public:
  94. CSearch( DBCOMMANDTREE * pRst,
  95. ICiCLangRes * pLangRes,
  96. ICiCOpenedDoc * pOpenedDoc );
  97. //
  98. // From IUnknown
  99. //
  100. virtual SCODE STDMETHODCALLTYPE QueryInterface(REFIID riid, void ** ppvObject);
  101. virtual ULONG STDMETHODCALLTYPE AddRef();
  102. virtual ULONG STDMETHODCALLTYPE Release();
  103. //
  104. // From ISearchQueryHits
  105. //
  106. virtual SCODE STDMETHODCALLTYPE Init(
  107. IFilter * pflt,
  108. ULONG ulFlags );
  109. virtual SCODE STDMETHODCALLTYPE NextHitMoniker(
  110. ULONG * pcMnk,
  111. IMoniker *** papMnk );
  112. virtual SCODE STDMETHODCALLTYPE NextHitOffset(
  113. ULONG * pcRegion,
  114. FILTERREGION ** paRegion );
  115. private:
  116. ~CSearch();
  117. long _cRefs;
  118. void ConvertPositionsToHit( LONG rank );
  119. void Reset ();
  120. CSearchKeyRepository* _pKeyRep; // The repository of keys
  121. CHitArray _aHit; // Array of hits
  122. unsigned _iCurHit;
  123. CStandardPropMapper _propMapper; // Mapper to convert properties to pids.
  124. // Must precede _pidcvt.
  125. CPidConverter _pidcvt; // Pid converter. Must precede _pidmap.
  126. CCursor* _pCursor; // cursor tree corresponding to a restriction
  127. XRestriction _xRst; // query restriction
  128. CPidMapper _pidmap;
  129. CLangList _langList;
  130. CHitSink _hitSink; // the sink for hits. filled by the cursor tree
  131. XInterface<ICiCOpenedDoc> _xOpenedDoc;
  132. };