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.

92 lines
2.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. //
  4. // CTrie - class CTrie encapsulation for Trie data structure.
  5. //
  6. // History:
  7. // created 6/99 aarayas
  8. //
  9. // �1999 Microsoft Corporation
  10. //----------------------------------------------------------------------------
  11. #ifndef _CTRIE_H_
  12. #define _CTRIE_H_
  13. #include <windows.h>
  14. #include <assert.h>
  15. #include <memory.h>
  16. #include "lexheader.h"
  17. #include "trie.h"
  18. //#include "NLGlib.h"
  19. #include "ProofBase.h"
  20. #include "thwbdef.hpp"
  21. #include "CFileManager.h"
  22. #define lidThai 0x41e
  23. #define lidViet 0x42a
  24. // 1111 0000 0000 0000 0000 0000 0000 0000 -- Alt Mask
  25. // 0000 1111 1111 1111 1111 0000 0000 0000 -- Pos Mas
  26. const int iDialectMask = 1;
  27. const int iRestrictedMask = 16;
  28. const int iPosMask = 268431360; // 0x0FFFF000
  29. const int iAltMask = 4026531840; // 0xF0000000
  30. const int iFrqShift = 8;
  31. const int iPosShift = 12;
  32. const int iAltShift = 28;
  33. class CTrie;
  34. class CTrieIter {
  35. public:
  36. // Initialization functions.
  37. CTrieIter();
  38. CTrieIter(const CTrieIter& trieIter);
  39. virtual void Init(CTrie*);
  40. virtual void Init(TRIECTRL*);
  41. // Interation functions.
  42. virtual void Reset();
  43. virtual BOOL Down();
  44. virtual BOOL Right();
  45. virtual void GetNode();
  46. // Local variables.
  47. WCHAR wc;
  48. BOOL fWordEnd;
  49. BOOL fRestricted;
  50. BYTE frq;
  51. DWORD posTag;
  52. DWORD dwTag; // Uncompress word tags.
  53. protected:
  54. //Trie
  55. TRIECTRL* pTrieCtrl;
  56. // Trie Iterator.
  57. TRIESCAN trieScan;
  58. };
  59. class CTrie {
  60. friend class CTrieIter;
  61. public:
  62. CTrie();
  63. ~CTrie();
  64. static PTEC retcode(int mjr, int mnr) { return MAKELONG(mjr, mnr); }
  65. bool Init(const WCHAR* szFileName);
  66. PTEC InitRc(LPBYTE lpMap, BOOL fSkipHeader);
  67. void UnInit();
  68. BOOL Find(const WCHAR* szWord, DWORD* pdwPOS);
  69. protected:
  70. // PMFILE pMapFile;
  71. TRIECTRL *pTrieCtrl;
  72. CTrieIter* pTrieScan;
  73. CFileManager* pFileManager;
  74. BYTE *m_pMap;
  75. // TRIECTRL * m_pTrieCtrl;
  76. };
  77. #endif