]> git.lyx.org Git - features.git/blob - 3rdparty/mythes/1.2.5/mythes.hxx
Amend b8502a3ea2735c4
[features.git] / 3rdparty / mythes / 1.2.5 / mythes.hxx
1 #ifndef _MYTHES_HXX_
2 #define _MYTHES_HXX_
3
4 // some maximum sizes for buffers
5 #define MAX_WD_LEN 200
6 #define MAX_LN_LEN 16384
7
8
9 // a meaning with definition, count of synonyms and synonym list
10 struct mentry {
11   char*  defn;
12   int  count;
13   char** psyns;
14 };
15
16
17 class MyThes
18 {
19
20        int  nw;                  /* number of entries in thesaurus */
21        char**  list;               /* stores word list */
22        unsigned int* offst;              /* stores offset list */
23        char *  encoding;           /* stores text encoding; */
24  
25         FILE  *pdfile;
26
27         // disallow copy-constructor and assignment-operator for now
28         MyThes();
29         MyThes(const MyThes &);
30         MyThes & operator = (const MyThes &);
31
32 public:
33         MyThes(const char* idxpath, const char* datpath);
34         ~MyThes();
35
36         // lookup text in index and return number of meanings
37         // each meaning entry has a defintion, synonym count and pointer 
38         // when complete return the *original* meaning entry and count via 
39         // CleanUpAfterLookup to properly handle memory deallocation
40
41         int Lookup(const char * pText, int len, mentry** pme); 
42
43         void CleanUpAfterLookup(mentry** pme, int nmean);
44
45         char* get_th_encoding(); 
46
47 private:
48         // Open index and dat files and load list array
49         int thInitialize (const char* indxpath, const char* datpath);
50         
51         // internal close and cleanup dat and idx files
52         void thCleanup ();
53
54         // read a text line (\n terminated) stripping off line terminator
55         int readLine(FILE * pf, char * buf, int nc);
56
57         // binary search on null terminated character strings
58         int binsearch(char * wrd, char* list[], int nlst);
59
60         // string duplication routine
61         char * mystrdup(const char * p);
62
63         // remove cross-platform text line end characters
64         void mychomp(char * s);
65
66         // return index of char in string
67         int mystr_indexOfChar(const char * d, int c);
68
69 };
70
71 #endif
72
73
74
75
76