Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
1 /******* BEGIN LICENSE BLOCK *******
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Initial Developers of the Original Code are Kevin Hendricks (MySpell)
15 * and László Németh (Hunspell). Portions created by the Initial Developers
16 * are Copyright (C) 2002-2005 the Initial Developers. All Rights Reserved.
17 *
18 * Contributor(s): Kevin Hendricks (kevin.hendricks@sympatico.ca)
19 * David Einstein (deinst@world.std.com)
20 * László Németh (nemethl@gyorsposta.hu)
21 * Caolan McNamara (caolanm@redhat.com)
22 * Davide Prina
23 * Giuseppe Modugno
24 * Gianluca Turconi
25 * Simon Brouwer
26 * Noll Janos
27 * Biro Arpad
28 * Goldman Eleonora
29 * Sarlos Tamas
30 * Bencsath Boldizsar
31 * Halacsy Peter
32 * Dvornik Laszlo
33 * Gefferth Andras
34 * Nagy Viktor
35 * Varga Daniel
36 * Chris Halls
37 * Rene Engelhard
38 * Bram Moolenaar
39 * Dafydd Jones
40 * Harri Pitkanen
41 * Andras Timar
42 * Tor Lillqvist
43 *
44 * Alternatively, the contents of this file may be used under the terms of
45 * either the GNU General Public License Version 2 or later (the "GPL"), or
46 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
47 * in which case the provisions of the GPL or the LGPL are applicable instead
48 * of those above. If you wish to allow use of your version of this file only
49 * under the terms of either the GPL or the LGPL, and not to allow others to
50 * use your version of this file under the terms of the MPL, indicate your
51 * decision by deleting the provisions above and replace them with the notice
52 * and other provisions required by the GPL or the LGPL. If you do not delete
53 * the provisions above, a recipient may use your version of this file under
54 * the terms of any one of the MPL, the GPL or the LGPL.
55 *
56 ******* END LICENSE BLOCK *******/
58 #ifndef _HASHMGR_HXX_
59 #define _HASHMGR_HXX_
61 #include "hunvisapi.h"
63 #include <stdio.h>
65 #include "htypes.hxx"
66 #include "filemgr.hxx"
68 enum flag { FLAG_CHAR, FLAG_LONG, FLAG_NUM, FLAG_UNI };
70 class LIBHUNSPELL_DLL_EXPORTED HashMgr
71 {
72 int tablesize;
73 struct hentry ** tableptr;
74 int userword;
75 flag flag_mode;
76 int complexprefixes;
77 int utf8;
78 unsigned short forbiddenword;
79 int langnum;
80 char * enc;
81 char * lang;
82 struct cs_info * csconv;
83 char * ignorechars;
84 unsigned short * ignorechars_utf16;
85 int ignorechars_utf16_len;
86 int numaliasf; // flag vector `compression' with aliases
87 unsigned short ** aliasf;
88 unsigned short * aliasflen;
89 int numaliasm; // morphological desciption `compression' with aliases
90 char ** aliasm;
93 public:
94 HashMgr(const char * tpath, const char * apath, const char * key = NULL);
95 ~HashMgr();
97 struct hentry * lookup(const char *) const;
98 int hash(const char *) const;
99 struct hentry * walk_hashtable(int & col, struct hentry * hp) const;
101 int add(const char * word);
102 int add_with_affix(const char * word, const char * pattern);
103 int remove(const char * word);
104 int decode_flags(unsigned short ** result, char * flags, FileMgr * af);
105 unsigned short decode_flag(const char * flag);
106 char * encode_flag(unsigned short flag);
107 int is_aliasf();
108 int get_aliasf(int index, unsigned short ** fvec, FileMgr * af);
109 int is_aliasm();
110 char * get_aliasm(int index);
112 private:
113 int get_clen_and_captype(const char * word, int wbl, int * captype);
114 int load_tables(const char * tpath, const char * key);
115 int add_word(const char * word, int wbl, int wcl, unsigned short * ap,
116 int al, const char * desc, bool onlyupcase);
117 int load_config(const char * affpath, const char * key);
118 int parse_aliasf(char * line, FileMgr * af);
119 int add_hidden_capitalized_word(char * word, int wbl, int wcl,
120 unsigned short * flags, int al, char * dp, int captype);
121 int parse_aliasm(char * line, FileMgr * af);
122 int remove_forbidden_flag(const char * word);
124 };
126 #endif