Leaked source code of windows server 2003
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.

141 lines
4.0 KiB

  1. #ifndef __ftsobj_H_
  2. #define __ftsobj_H_
  3. #include "stdafx.h"
  4. #include "msitstg.h"
  5. #include <initguid.h>
  6. #include "itrs.h"
  7. #include "itdb.h"
  8. #include "iterror.h"
  9. #include "itgroup.h"
  10. #include "itpropl.h"
  11. #include "itquery.h"
  12. #include "itcc.h"
  13. #include "titleinfo.h"
  14. ////////////////////////////////////////////////////////////////////////////////
  15. //
  16. // DON'T TOUCH, FROM HHCTRL SOURCE CODE!!!!!
  17. //
  18. typedef struct CHM_MapEntry
  19. {
  20. char szChmName[50];
  21. WORD iIndex;
  22. FILETIME versioninfo;
  23. LCID language;
  24. DWORD dwOutDated;
  25. } CHM_MAP_ENTRY;
  26. //
  27. // DON'T TOUCH, FROM HHCTRL SOURCE CODE!!!!!
  28. //
  29. ////////////////////////////////////////////////////////////////////////////////
  30. struct SEARCH_RESULT
  31. {
  32. MPC::wstring strChmName;
  33. CComBSTR bstrTopicName;
  34. CComBSTR bstrLocation;
  35. CComBSTR bstrTopicURL;
  36. DWORD dwRank;
  37. SEARCH_RESULT()
  38. {
  39. dwRank = 0;
  40. }
  41. bool operator< ( /*[in]*/ SEARCH_RESULT const &res ) const
  42. {
  43. return MPC::StrICmp( bstrTopicURL, res.bstrTopicURL ) < 0;
  44. }
  45. };
  46. typedef std::set< SEARCH_RESULT > SEARCH_RESULT_SET;
  47. typedef SEARCH_RESULT_SET::iterator SEARCH_RESULT_SET_ITER;
  48. typedef SEARCH_RESULT_SET::const_iterator SEARCH_RESULT_SET_ITERCONST;
  49. class SEARCH_RESULT_SORTER
  50. {
  51. public:
  52. bool operator()( SEARCH_RESULT* left, SEARCH_RESULT* right )
  53. {
  54. //
  55. // Rank is sorted from highest to lowest, so negate iCmp;
  56. //
  57. int iCmp = -(left->dwRank - right->dwRank);
  58. if(iCmp < 0) return true;
  59. if(iCmp > 0) return false;
  60. return MPC::StrICmp( left->bstrTopicName, right->bstrTopicName ) <= 0;
  61. }
  62. };
  63. typedef std::set< SEARCH_RESULT*, SEARCH_RESULT_SORTER > SEARCH_RESULT_SORTSET;
  64. typedef SEARCH_RESULT_SORTSET::iterator SEARCH_RESULT_SORTSET_ITER;
  65. typedef SEARCH_RESULT_SORTSET::const_iterator SEARCH_RESULT_SORTSET_ITERCONST;
  66. ////////////////////////////////////////////////////////////////////////////////
  67. class CFTSObject
  68. {
  69. public:
  70. struct Config
  71. {
  72. MPC::wstring m_strCHMFilename;
  73. MPC::wstring m_strCHQFilename;
  74. bool m_fCombined;
  75. DWORD m_dwMaxResult;
  76. WORD m_wQueryProximity;
  77. Config()
  78. {
  79. m_fCombined = false;
  80. m_dwMaxResult = 500;
  81. m_wQueryProximity = 8;
  82. }
  83. };
  84. private:
  85. Config m_cfg;
  86. bool m_fInitialized;
  87. MPC::wstring m_strCHQPath;
  88. LCID m_lcidLang;
  89. FILETIME m_ftVersionInfo;
  90. DWORD m_dwTopicCount;
  91. WORD m_wIndex;
  92. bool m_fOutDated;
  93. CHM_MAP_ENTRY* m_cmeCHMInfo;
  94. WORD m_wCHMInfoCount;
  95. CComPtr<IITIndex> m_pIndex;
  96. CComPtr<IITQuery> m_pQuery;
  97. CComPtr<IITResultSet> m_pITResultSet;
  98. CComPtr<IITDatabase> m_pITDB;
  99. ////////////////////
  100. void BuildChmPath( /*[in/out]*/ MPC::wstring& strPath, /*[in]*/ LPCSTR szChmName );
  101. HRESULT Initialize ( );
  102. HRESULT LoadCombinedIndex( );
  103. HRESULT ResetQuery ( /*[in]*/ LPCWSTR szQuery );
  104. HRESULT ProcessResult ( /*[in/out]*/ SEARCH_RESULT_SET& results, /*[in/out]*/ MPC::WStringSet& words, UINT cp );
  105. public:
  106. CFTSObject();
  107. ~CFTSObject();
  108. Config& GetConfig() { return m_cfg; }
  109. HRESULT Query( /*[in]*/ LPCWSTR wszQuery, /*[in]*/ bool bTitle, /*[in]*/ bool bStemming, /*[in/out]*/ SEARCH_RESULT_SET& results, /*[in/out]*/ MPC::WStringSet& words, UINT cp );
  110. };
  111. typedef std::list< CFTSObject > SEARCH_OBJECT_LIST;
  112. typedef SEARCH_OBJECT_LIST::iterator SEARCH_OBJECT_LIST_ITER;
  113. typedef SEARCH_OBJECT_LIST::const_iterator SEARCH_OBJECT_LIST_ITERCONST;
  114. #endif