PageRenderTime 25ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/mythes-1.2.3/mythes.hxx

#
C++ Header | 76 lines | 35 code | 27 blank | 14 comment | 0 complexity | dda73454269ce030222d399b7be2b635 MD5 | raw file
  1. #ifndef _MYTHES_HXX_
  2. #define _MYTHES_HXX_
  3. // some maximum sizes for buffers
  4. #define MAX_WD_LEN 200
  5. #define MAX_LN_LEN 16384
  6. // a meaning with definition, count of synonyms and synonym list
  7. struct mentry {
  8. char* defn;
  9. int count;
  10. char** psyns;
  11. };
  12. class MyThes
  13. {
  14. int nw; /* number of entries in thesaurus */
  15. char** list; /* stores word list */
  16. unsigned int* offst; /* stores offset list */
  17. char * encoding; /* stores text encoding; */
  18. FILE *pdfile;
  19. // disallow copy-constructor and assignment-operator for now
  20. MyThes();
  21. MyThes(const MyThes &);
  22. MyThes & operator = (const MyThes &);
  23. public:
  24. MyThes(const char* idxpath, const char* datpath);
  25. ~MyThes();
  26. // lookup text in index and return number of meanings
  27. // each meaning entry has a defintion, synonym count and pointer
  28. // when complete return the *original* meaning entry and count via
  29. // CleanUpAfterLookup to properly handle memory deallocation
  30. int Lookup(const char * pText, int len, mentry** pme);
  31. void CleanUpAfterLookup(mentry** pme, int nmean);
  32. char* get_th_encoding();
  33. private:
  34. // Open index and dat files and load list array
  35. int thInitialize (const char* indxpath, const char* datpath);
  36. // internal close and cleanup dat and idx files
  37. void thCleanup ();
  38. // read a text line (\n terminated) stripping off line terminator
  39. int readLine(FILE * pf, char * buf, int nc);
  40. // binary search on null terminated character strings
  41. int binsearch(char * wrd, char* list[], int nlst);
  42. // string duplication routine
  43. char * mystrdup(const char * p);
  44. // remove cross-platform text line end characters
  45. void mychomp(char * s);
  46. // return index of char in string
  47. int mystr_indexOfChar(const char * d, int c);
  48. };
  49. #endif