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.

184 lines
5.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 2000.
  5. //
  6. // File: QKREP.HXX
  7. //
  8. // Contents: Query Key Repository
  9. //
  10. // Classes: CQueryKeyRepository
  11. //
  12. // History: 30-May-91 t-WadeR Created.
  13. // 23-Sep-91 BartoszM Rewrote to use phrase expr.
  14. //
  15. //----------------------------------------------------------------------------
  16. #pragma once
  17. #include <lang.hxx>
  18. #include <plang.hxx>
  19. class CRestriction;
  20. class CNodeRestriction;
  21. class CPhraseRestriction;
  22. DECL_DYNSTACK( CPhraseRstStack, CPhraseRestriction );
  23. DECLARE_SMARTP( PhraseRestriction );
  24. DECLARE_SMARTP( OccRestriction );
  25. DECLARE_SMARTP( WordRestriction );
  26. //+---------------------------------------------------------------------------
  27. //
  28. // Class: CQueryKeyRepository
  29. //
  30. // Purpose: Key repository for word repository
  31. //
  32. // History: 30-May-91 t-WadeR Created.
  33. // 23-Sep-91 BartoszM Rewrote to use phrase expr.
  34. //
  35. //----------------------------------------------------------------------------
  36. class CQueryKeyRepository: public PKeyRepository
  37. {
  38. public:
  39. CQueryKeyRepository( ULONG fuzzy );
  40. ~CQueryKeyRepository();
  41. BOOL PutPropId ( PROPID pid ) { _key.SetPid(pid); return TRUE; }
  42. void PutKey ( ULONG cNoiseWordsSkipped = 0 );
  43. void StartAltPhrase( ULONG cNoiseWordsSkipped );
  44. void EndAltPhrase( ULONG cNoiseWordsSkipped );
  45. void GetBuffers( UINT** ppcbWordBuf,
  46. BYTE** ppbWordBuf,
  47. OCCURRENCE** ppocc );
  48. void GetFlags ( BOOL** ppRange, CI_RANK** ppRank );
  49. CRestriction * AcqRst();
  50. void PutWorkId ( WORKID ) { ciAssert (0); }
  51. inline const ULONG GetFilteredBlockCount() const
  52. {
  53. Win4Assert(!"Function not supported in this class!");
  54. return 0;
  55. }
  56. void FixUp( CDataRepository & drep );
  57. private:
  58. void AppendKey( CPhraseRestriction *pPhraseRst, ULONG cNoiseWordsSkipped );
  59. void CloneAndAdd( CNodeRestriction *pOrRst,
  60. CPhraseRestriction *pHeadPhrase,
  61. CPhraseRestriction *pTailPhrase );
  62. OCCURRENCE CQueryKeyRepository::_ComputeOccurrence( COccRestriction *pOccRst,
  63. CPhraseRestriction *pPhraseRst );
  64. BOOL _fHasSynonym; // We want to know if word breaking
  65. // has occured. That's not possible to know
  66. // because, we don't know if the PutAltWord
  67. // is called for synonym or a non-space word
  68. // breaking (e.g. German)
  69. CKeyBuf _key;
  70. OCCURRENCE _occ;
  71. BOOL _isRange;
  72. CI_RANK _rank;
  73. OCCURRENCE _occLast;
  74. CPhraseRstStack _stkAltPhrases; // stack for alternate phrases
  75. CPhraseRestriction *_pPhrase; // a single phrase, or
  76. CNodeRestriction *_pOrRst; // 'or' node of phrases
  77. CPhraseRestriction *_pCurAltPhrase; // current alternate phrase
  78. ULONG _cInitialNoiseWords;
  79. BOOL _fNoiseWordsOnly; // does an alt phrase have noise words only
  80. };
  81. //+---------------------------------------------------------------------------
  82. //
  83. // Class: CVectorKeyRepository
  84. //
  85. // Purpose: Vector key repository for natural language queries
  86. //
  87. // History: 18-Jan-95 SitaramR Created.
  88. //
  89. //----------------------------------------------------------------------------
  90. class CVectorKeyRepository: public PKeyRepository, public IPhraseSink
  91. {
  92. public:
  93. CVectorKeyRepository( const CFullPropSpec & ps, LCID lcid, ULONG ulWeight, CPidMapper & pidmap, CLangList & langList );
  94. ~CVectorKeyRepository();
  95. // PKeyRepository functions
  96. BOOL PutPropId ( PROPID pid ) { _key.SetPid(pid); return TRUE; }
  97. void PutKey ( ULONG cNoiseWordsSkipped = 0 );
  98. // ignore alternate phrases
  99. void StartAltPhrase( ULONG cNoiseWordsSkipped ) {}
  100. void EndAltPhrase( ULONG cNoiseWordsSkipped ) {}
  101. void PutWorkId ( WORKID ) { Win4Assert(!"Function not supported in this class!"); }
  102. void GetBuffers( UINT** ppcbWordBuf,
  103. BYTE** ppbWordBuf,
  104. OCCURRENCE** ppocc );
  105. void GetFlags ( BOOL** ppRange, CI_RANK** ppRank );
  106. CVectorRestriction* AcqRst();
  107. const ULONG GetFilteredBlockCount() const
  108. {
  109. Win4Assert(!"Function not supported in this class!");
  110. return 0;
  111. }
  112. // IPhraseSink functions
  113. virtual SCODE STDMETHODCALLTYPE PutPhrase( WCHAR const *pwcPhrase, ULONG cwcPhrase );
  114. virtual SCODE STDMETHODCALLTYPE PutSmallPhrase( WCHAR const *pwcNoun,
  115. ULONG cwcNoun,
  116. WCHAR const *pwcModifier,
  117. ULONG cwcModifier,
  118. ULONG ulAttachmentType)
  119. {
  120. Win4Assert( !"PutSmallPhrase - Not yet implemented" );
  121. return PSINK_E_INDEX_ONLY;
  122. }
  123. // IUnknown functions
  124. virtual SCODE STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
  125. virtual ULONG STDMETHODCALLTYPE AddRef();
  126. virtual ULONG STDMETHODCALLTYPE Release();
  127. private:
  128. CKeyBuf _key;
  129. OCCURRENCE _occ;
  130. CVectorRestriction* _pVectorRst;
  131. OCCURRENCE _occLast;
  132. const CFullPropSpec & _ps;
  133. LCID _lcid;
  134. ULONG _ulWeight;
  135. CPidMapper & _pidMap;
  136. CLangList & _langList;
  137. };