| OLD | NEW |
| 1 #ifndef _AFFIXMGR_HXX_ | 1 #ifndef _AFFIXMGR_HXX_ |
| 2 #define _AFFIXMGR_HXX_ | 2 #define _AFFIXMGR_HXX_ |
| 3 | 3 |
| 4 #include "hunvisapi.h" | 4 #include "hunvisapi.h" |
| 5 | 5 |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 | 7 |
| 8 #include "atypes.hxx" | 8 #include "atypes.hxx" |
| 9 #include "baseaffix.hxx" | 9 #include "baseaffix.hxx" |
| 10 #include "hashmgr.hxx" | 10 #include "hashmgr.hxx" |
| 11 #include "phonet.hxx" | 11 #include "phonet.hxx" |
| 12 #include "replist.hxx" | 12 #include "replist.hxx" |
| 13 | 13 |
| 14 // check flag duplication | 14 // check flag duplication |
| 15 #define dupSFX (1 << 0) | 15 #define dupSFX (1 << 0) |
| 16 #define dupPFX (1 << 1) | 16 #define dupPFX (1 << 1) |
| 17 | 17 |
| 18 class PfxEntry; | 18 class PfxEntry; |
| 19 class SfxEntry; | 19 class SfxEntry; |
| 20 | 20 |
| 21 #ifdef HUNSPELL_CHROME_CLIENT |
| 22 |
| 23 #include <vector> |
| 24 |
| 25 // This class provides an implementation of the contclasses array in AffixMgr |
| 26 // that is normally a large static array. We should almost never need more than |
| 27 // 256 elements, so this class only allocates that much to start off with. If |
| 28 // elements higher than that are actually used, we'll automatically expand. |
| 29 class ContClasses { |
| 30 public: |
| 31 ContClasses() { |
| 32 // Pre-allocate a buffer so that typically, we'll never have to resize. |
| 33 EnsureSizeIs(256); |
| 34 } |
| 35 |
| 36 char& operator[](size_t index) { |
| 37 EnsureSizeIs(index + 1); |
| 38 return data[index]; |
| 39 } |
| 40 |
| 41 void EnsureSizeIs(size_t new_size) { |
| 42 if (data.size() >= new_size) |
| 43 return; // Nothing to do. |
| 44 |
| 45 size_t old_size = data.size(); |
| 46 data.resize(new_size); |
| 47 memset(&data[old_size], 0, new_size - old_size); |
| 48 } |
| 49 |
| 50 std::vector<char> data; |
| 51 }; |
| 52 |
| 53 #endif // HUNSPELL_CHROME_CLIENT |
| 54 |
| 21 class LIBHUNSPELL_DLL_EXPORTED AffixMgr | 55 class LIBHUNSPELL_DLL_EXPORTED AffixMgr |
| 22 { | 56 { |
| 23 | 57 |
| 24 PfxEntry * pStart[SETSIZE]; | 58 PfxEntry * pStart[SETSIZE]; |
| 25 SfxEntry * sStart[SETSIZE]; | 59 SfxEntry * sStart[SETSIZE]; |
| 26 PfxEntry * pFlag[SETSIZE]; | 60 PfxEntry * pFlag[SETSIZE]; |
| 27 SfxEntry * sFlag[SETSIZE]; | 61 SfxEntry * sFlag[SETSIZE]; |
| 28 HashMgr * pHMgr; | 62 HashMgr * pHMgr; |
| 29 HashMgr ** alldic; | 63 HashMgr ** alldic; |
| 30 int * maxdic; | 64 int * maxdic; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 int langnum; | 125 int langnum; |
| 92 FLAG lemma_present; | 126 FLAG lemma_present; |
| 93 FLAG circumfix; | 127 FLAG circumfix; |
| 94 FLAG onlyincompound; | 128 FLAG onlyincompound; |
| 95 FLAG keepcase; | 129 FLAG keepcase; |
| 96 FLAG substandard; | 130 FLAG substandard; |
| 97 int checksharps; | 131 int checksharps; |
| 98 int fullstrip; | 132 int fullstrip; |
| 99 | 133 |
| 100 int havecontclass; // boolean variable | 134 int havecontclass; // boolean variable |
| 135 #ifdef HUNSPELL_CHROME_CLIENT |
| 136 ContClasses contclasses; |
| 137 #else |
| 101 char contclasses[CONTSIZE]; // flags of possible continuing cla
sses (twofold affix) | 138 char contclasses[CONTSIZE]; // flags of possible continuing cla
sses (twofold affix) |
| 139 #endif |
| 102 | 140 |
| 103 public: | 141 public: |
| 104 | 142 |
| 143 #ifdef HUNSPELL_CHROME_CLIENT |
| 144 AffixMgr(hunspell::BDictReader* reader, HashMgr** ptr, int * md); |
| 145 #else |
| 105 AffixMgr(const char * affpath, HashMgr** ptr, int * md, | 146 AffixMgr(const char * affpath, HashMgr** ptr, int * md, |
| 106 const char * key = NULL); | 147 const char * key = NULL); |
| 148 #endif |
| 107 ~AffixMgr(); | 149 ~AffixMgr(); |
| 108 struct hentry * affix_check(const char * word, int len, | 150 struct hentry * affix_check(const char * word, int len, |
| 109 const unsigned short needflag = (unsigned short) 0, | 151 const unsigned short needflag = (unsigned short) 0, |
| 110 char in_compound = IN_CPD_NOT); | 152 char in_compound = IN_CPD_NOT); |
| 111 struct hentry * prefix_check(const char * word, int len, | 153 struct hentry * prefix_check(const char * word, int len, |
| 112 char in_compound, const FLAG needflag = FLAG_NULL); | 154 char in_compound, const FLAG needflag = FLAG_NULL); |
| 113 inline int isSubset(const char * s1, const char * s2); | 155 inline int isSubset(const char * s1, const char * s2); |
| 114 struct hentry * prefix_check_twosfx(const char * word, int len, | 156 struct hentry * prefix_check_twosfx(const char * word, int len, |
| 115 char in_compound, const FLAG needflag = FLAG_NULL); | 157 char in_compound, const FLAG needflag = FLAG_NULL); |
| 116 inline int isRevSubset(const char * s1, const char * end_of_s2, int len); | 158 inline int isRevSubset(const char * s1, const char * end_of_s2, int len); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 char * get_suffixed(char ) const; | 237 char * get_suffixed(char ) const; |
| 196 int get_maxngramsugs() const; | 238 int get_maxngramsugs() const; |
| 197 int get_nosplitsugs() const; | 239 int get_nosplitsugs() const; |
| 198 int get_sugswithdots(void) const; | 240 int get_sugswithdots(void) const; |
| 199 FLAG get_keepcase(void) const; | 241 FLAG get_keepcase(void) const; |
| 200 int get_checksharps(void) const; | 242 int get_checksharps(void) const; |
| 201 char * encode_flag(unsigned short aflag) const; | 243 char * encode_flag(unsigned short aflag) const; |
| 202 int get_fullstrip() const; | 244 int get_fullstrip() const; |
| 203 | 245 |
| 204 private: | 246 private: |
| 247 #ifdef HUNSPELL_CHROME_CLIENT |
| 248 // Not owned by us, owned by the Hunspell object. |
| 249 hunspell::BDictReader* bdict_reader; |
| 250 #endif |
| 205 int parse_file(const char * affpath, const char * key); | 251 int parse_file(const char * affpath, const char * key); |
| 206 int parse_flag(char * line, unsigned short * out, FileMgr * af); | 252 int parse_flag(char * line, unsigned short * out, FileMgr * af); |
| 207 int parse_num(char * line, int * out, FileMgr * af); | 253 int parse_num(char * line, int * out, FileMgr * af); |
| 208 int parse_cpdsyllable(char * line, FileMgr * af); | 254 int parse_cpdsyllable(char * line, FileMgr * af); |
| 209 int parse_reptable(char * line, FileMgr * af); | 255 int parse_reptable(char * line, FileMgr * af); |
| 210 int parse_convtable(char * line, FileMgr * af, RepList ** rl, const char * ke
yword); | 256 int parse_convtable(char * line, FileMgr * af, RepList ** rl, const char * ke
yword); |
| 211 int parse_phonetable(char * line, FileMgr * af); | 257 int parse_phonetable(char * line, FileMgr * af); |
| 212 int parse_maptable(char * line, FileMgr * af); | 258 int parse_maptable(char * line, FileMgr * af); |
| 213 int parse_breaktable(char * line, FileMgr * af); | 259 int parse_breaktable(char * line, FileMgr * af); |
| 214 int parse_checkcpdtable(char * line, FileMgr * af); | 260 int parse_checkcpdtable(char * line, FileMgr * af); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 226 PfxEntry * process_pfx_in_order(PfxEntry * ptr, PfxEntry * nptr); | 272 PfxEntry * process_pfx_in_order(PfxEntry * ptr, PfxEntry * nptr); |
| 227 SfxEntry * process_sfx_in_order(SfxEntry * ptr, SfxEntry * nptr); | 273 SfxEntry * process_sfx_in_order(SfxEntry * ptr, SfxEntry * nptr); |
| 228 int process_pfx_tree_to_list(); | 274 int process_pfx_tree_to_list(); |
| 229 int process_sfx_tree_to_list(); | 275 int process_sfx_tree_to_list(); |
| 230 int redundant_condition(char, char * strip, int stripl, | 276 int redundant_condition(char, char * strip, int stripl, |
| 231 const char * cond, int); | 277 const char * cond, int); |
| 232 }; | 278 }; |
| 233 | 279 |
| 234 #endif | 280 #endif |
| 235 | 281 |
| OLD | NEW |