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.

88 lines
1.8 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. #define lidThai 0x41e
  22. #define lidViet 0x42a
  23. // 1111 0000 0000 0000 0000 0000 0000 0000 -- Alt Mask
  24. // 0000 1111 1111 1111 1111 0000 0000 0000 -- Pos Mas
  25. const int iDialectMask = 1;
  26. const int iRestrictedMask = 16;
  27. const int iPosMask = 268431360; // 0x0FFFF000
  28. const int iAltMask = 4026531840; // 0xF0000000
  29. const int iFrqShift = 8;
  30. const int iPosShift = 12;
  31. const int iAltShift = 28;
  32. class CTrie;
  33. class CTrieIter {
  34. public:
  35. // Initialization functions.
  36. CTrieIter();
  37. CTrieIter(const CTrieIter& trieIter);
  38. virtual void Init(CTrie*);
  39. virtual void Init(TRIECTRL*);
  40. // Interation functions.
  41. virtual void Reset();
  42. virtual BOOL Down();
  43. virtual BOOL Right();
  44. virtual void GetNode();
  45. // Local variables.
  46. WCHAR wc;
  47. BOOL fWordEnd;
  48. BOOL fRestricted;
  49. BYTE frq;
  50. DWORD posTag;
  51. DWORD dwTag; // Uncompress word tags.
  52. protected:
  53. //Trie
  54. TRIECTRL* pTrieCtrl;
  55. // Trie Iterator.
  56. TRIESCAN trieScan;
  57. };
  58. class CTrie {
  59. friend class CTrieIter;
  60. public:
  61. CTrie();
  62. ~CTrie();
  63. static PTEC retcode(int mjr, int mnr) { return MAKELONG(mjr, mnr); }
  64. PTEC Init(WCHAR* szFileName);
  65. PTEC InitRc(LPBYTE);
  66. void UnInit();
  67. BOOL Find(WCHAR* szWord, DWORD* pdwPOS);
  68. protected:
  69. PMFILE pMapFile;
  70. TRIECTRL *pTrieCtrl;
  71. // CTrieIter trieScan;
  72. CTrieIter* pTrieScan;
  73. };
  74. #endif