| 1 | #cxx . . $ `<file>/mythes.hxx`/ifndef _MYTHES_HXX_ |
| 2 | #define _MYTHES_HXX_cxx . . $ `mythes.hxx:2:9`! |
| 3 | |
| 4 | // some maximum sizes for buffers |
| 5 | #define MAX_WD_LENcxx . . $ `mythes.hxx:5:9`! 200 |
| 6 | #define MAX_LN_LENcxx . . $ `mythes.hxx:6:9`! 16384 |
| 7 | |
| 8 | // Sanity cap on the meaning count parsed from .dat. en_US peaks at 72 |
| 9 | // meanings ("cut"/"break") and the OED claims ~645 senses for "run", |
| 10 | // so 8192 leaves an order of magnitude of headroom. |
| 11 | #define MAX_MEANINGScxx . . $ `mythes.hxx:11:9`! 8192 |
| 12 | |
| 13 | |
| 14 | // a meaning with definition, count of synonyms and synonym list |
| 15 | struct mentrycxx . . $ mentry# { |
| 16 | char* defncxx . . $ mentry#defn.; |
| 17 | int countcxx . . $ mentry#count.; |
| 18 | char** psynscxx . . $ mentry#psyns.; |
| 19 | }; |
| 20 | |
| 21 | |
| 22 | class MyThescxx . . $ MyThes# |
| 23 | { |
| 24 | |
| 25 | int nwcxx . . $ MyThes#nw.; /* number of entries in thesaurus */ |
| 26 | char** listcxx . . $ MyThes#list.; /* stores word list */ |
| 27 | unsigned int* offstcxx . . $ MyThes#offst.; /* stores offset list */ |
| 28 | char * encodingcxx . . $ MyThes#encoding.; /* stores text encoding; */ |
| 29 | |
| 30 | FILE *pdfilecxx . . $ MyThes#pdfile.; |
| 31 | |
| 32 | // disallow copy-constructor and assignment-operator for now |
| 33 | MyThescxx . . $ MyThes#MyThes(49f6e7a06ebc5aa8).(); |
| 34 | MyThescxx . . $ MyThes#MyThes(f9b917cb5a56521).(const MyThescxx . . $ MyThes# &); |
| 35 | MyThescxx . . $ MyThes# & operatorcxx . . $ MyThes#`operator=`(92f98bf962774eeb). = (const MyThescxx . . $ MyThes# &); |
| 36 | |
| 37 | public: |
| 38 | // use UTF-8 encoded paths in WIN32 environment |
| 39 | MyThescxx . . $ MyThes#MyThes(2fa786934fe80e24).(const char* idxpath, const char* datpath); |
| 40 | ~cxx . . $ MyThes#`~MyThes`(ced63f7c635d850d).MyThescxx . . $ MyThes#(); |
| 41 | |
| 42 | // lookup text in index and return number of meanings |
| 43 | // each meaning entry has a defintion, synonym count and pointer |
| 44 | // when complete return the *original* meaning entry and count via |
| 45 | // CleanUpAfterLookup to properly handle memory deallocation |
| 46 | |
| 47 | int Lookupcxx . . $ MyThes#Lookup(37e48a0f27903be7).(const char * pText, int len, mentrycxx . . $ mentry#** pme); |
| 48 | |
| 49 | void CleanUpAfterLookupcxx . . $ MyThes#CleanUpAfterLookup(a7687779855b3463).(mentrycxx . . $ mentry#** pme, int nmean); |
| 50 | |
| 51 | char* get_th_encodingcxx . . $ MyThes#get_th_encoding(41208ce6ca65dd58).(); |
| 52 | |
| 53 | private: |
| 54 | // Open index and dat files and load list array |
| 55 | int thInitializecxx . . $ MyThes#thInitialize(5ae29d726ae57f88). (const char* indxpath, const char* datpath); |
| 56 | |
| 57 | // internal close and cleanup dat and idx files |
| 58 | void thCleanupcxx . . $ MyThes#thCleanup(49f6e7a06ebc5aa8). (); |
| 59 | |
| 60 | // read a text line (\n terminated) stripping off line terminator |
| 61 | int readLinecxx . . $ MyThes#readLine(324bcb2c939f72bd).(FILE * pf, char * buf, int nc); |
| 62 | |
| 63 | // binary search on null terminated character strings |
| 64 | int binsearchcxx . . $ MyThes#binsearch(f88ce9b05b61235f).(char * wrd, char* list[], int nlst); |
| 65 | |
| 66 | // string duplication routine |
| 67 | char * mystrdupcxx . . $ MyThes#mystrdup(a8b8e32347182212).(const char * p); |
| 68 | |
| 69 | // remove cross-platform text line end characters |
| 70 | void mychompcxx . . $ MyThes#mychomp(fda57c8427c60377).(char * s); |
| 71 | |
| 72 | // return index of char in string |
| 73 | int mystr_indexOfCharcxx . . $ MyThes#mystr_indexOfChar(cb7559238bb26814).(const char * d, int c); |
| 74 | |
| 75 | // fopen or _wfopen |
| 76 | FILE * myfopencxx . . $ MyThes#myfopen(82ec0787cd37e0a3).(const char * path, const char * mode); |
| 77 | |
| 78 | }; |
| 79 | |
| 80 | #endif |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 |