hashmgr.hxx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef _HASHMGR_HXX_
  2. #define _HASHMGR_HXX_
  3. #include "hunvisapi.h"
  4. #include <stdio.h>
  5. #include "htypes.hxx"
  6. #include "filemgr.hxx"
  7. enum flag { FLAG_CHAR, FLAG_LONG, FLAG_NUM, FLAG_UNI };
  8. class LIBHUNSPELL_DLL_EXPORTED HashMgr
  9. {
  10. int tablesize;
  11. struct hentry ** tableptr;
  12. int userword;
  13. flag flag_mode;
  14. int complexprefixes;
  15. int utf8;
  16. unsigned short forbiddenword;
  17. int langnum;
  18. char * enc;
  19. char * lang;
  20. struct cs_info * csconv;
  21. char * ignorechars;
  22. unsigned short * ignorechars_utf16;
  23. int ignorechars_utf16_len;
  24. int numaliasf; // flag vector `compression' with aliases
  25. unsigned short ** aliasf;
  26. unsigned short * aliasflen;
  27. int numaliasm; // morphological desciption `compression' with aliases
  28. char ** aliasm;
  29. public:
  30. HashMgr(const char * tpath, const char * apath, const char * key = NULL);
  31. ~HashMgr();
  32. struct hentry * lookup(const char *) const;
  33. int hash(const char *) const;
  34. struct hentry * walk_hashtable(int & col, struct hentry * hp) const;
  35. int add(const char * word);
  36. int add_with_affix(const char * word, const char * pattern);
  37. int remove(const char * word);
  38. int decode_flags(unsigned short ** result, char * flags, FileMgr * af);
  39. unsigned short decode_flag(const char * flag);
  40. char * encode_flag(unsigned short flag);
  41. int is_aliasf();
  42. int get_aliasf(int index, unsigned short ** fvec, FileMgr * af);
  43. int is_aliasm();
  44. char * get_aliasm(int index);
  45. private:
  46. int get_clen_and_captype(const char * word, int wbl, int * captype);
  47. int load_tables(const char * tpath, const char * key);
  48. int add_word(const char * word, int wbl, int wcl, unsigned short * ap,
  49. int al, const char * desc, bool onlyupcase);
  50. int load_config(const char * affpath, const char * key);
  51. int parse_aliasf(char * line, FileMgr * af);
  52. int add_hidden_capitalized_word(char * word, int wbl, int wcl,
  53. unsigned short * flags, int al, char * dp, int captype);
  54. int parse_aliasm(char * line, FileMgr * af);
  55. int remove_forbidden_flag(const char * word);
  56. };
  57. #endif