Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / extensions / spellcheck / hunspell / src / hashmgr.hxx
blob720009a6a789bef020694fea23a6cfcb389de5ce
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.
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.
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 * Davide Prina
22 * Giuseppe Modugno
23 * Gianluca Turconi
24 * Simon Brouwer
25 * Noll Janos
26 * Biro Arpad
27 * Goldman Eleonora
28 * Sarlos Tamas
29 * Bencsath Boldizsar
30 * Halacsy Peter
31 * Dvornik Laszlo
32 * Gefferth Andras
33 * Nagy Viktor
34 * Varga Daniel
35 * Chris Halls
36 * Rene Engelhard
37 * Bram Moolenaar
38 * Dafydd Jones
39 * Harri Pitkanen
40 * Andras Timar
41 * Tor Lillqvist
43 * Alternatively, the contents of this file may be used under the terms of
44 * either the GNU General Public License Version 2 or later (the "GPL"), or
45 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
46 * in which case the provisions of the GPL or the LGPL are applicable instead
47 * of those above. If you wish to allow use of your version of this file only
48 * under the terms of either the GPL or the LGPL, and not to allow others to
49 * use your version of this file under the terms of the MPL, indicate your
50 * decision by deleting the provisions above and replace them with the notice
51 * and other provisions required by the GPL or the LGPL. If you do not delete
52 * the provisions above, a recipient may use your version of this file under
53 * the terms of any one of the MPL, the GPL or the LGPL.
55 ******* END LICENSE BLOCK *******/
57 #ifndef _HASHMGR_HXX_
58 #define _HASHMGR_HXX_
60 #ifndef MOZILLA_CLIENT
61 #include <cstdio>
62 #else
63 #include <stdio.h>
64 #endif
66 #include "filemgr.hxx"
67 #include "htypes.hxx"
69 enum flag { FLAG_CHAR, FLAG_LONG, FLAG_NUM, FLAG_UNI };
71 class HashMgr
73 int tablesize;
74 struct hentry ** tableptr;
75 int userword;
76 flag flag_mode;
77 int complexprefixes;
78 int utf8;
79 unsigned short forbiddenword;
80 int langnum;
81 char * enc;
82 char * lang;
83 struct cs_info * csconv;
84 char * ignorechars;
85 unsigned short * ignorechars_utf16;
86 int ignorechars_utf16_len;
87 int numaliasf; // flag vector `compression' with aliases
88 unsigned short ** aliasf;
89 unsigned short * aliasflen;
90 int numaliasm; // morphological desciption `compression' with aliases
91 char ** aliasm;
94 public:
95 HashMgr(const char * tpath, const char * apath, const char * key = NULL);
96 ~HashMgr();
98 struct hentry * lookup(const char *) const;
99 int hash(const char *) const;
100 struct hentry * walk_hashtable(int & col, struct hentry * hp) const;
102 int add(const char * word);
103 int add_with_affix(const char * word, const char * pattern);
104 int remove(const char * word);
105 int decode_flags(unsigned short ** result, char * flags, FileMgr * af);
106 unsigned short decode_flag(const char * flag);
107 char * encode_flag(unsigned short flag);
108 int is_aliasf();
109 int get_aliasf(int index, unsigned short ** fvec, FileMgr * af);
110 int is_aliasm();
111 char * get_aliasm(int index);
113 private:
114 int get_clen_and_captype(const char * word, int wbl, int * captype);
115 int load_tables(const char * tpath, const char * key);
116 int add_word(const char * word, int wbl, int wcl, unsigned short * ap,
117 int al, const char * desc, bool onlyupcase);
118 int load_config(const char * affpath, const char * key);
119 int parse_aliasf(char * line, FileMgr * af);
120 int add_hidden_capitalized_word(char * word, int wbl, int wcl,
121 unsigned short * flags, int al, char * dp, int captype);
122 int parse_aliasm(char * line, FileMgr * af);
123 int remove_forbidden_flag(const char * word);
127 #endif