1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/extensions/spellcheck/hunspell/src/hashmgr.hxx Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,126 @@ 1.4 +/******* BEGIN LICENSE BLOCK ******* 1.5 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 1.6 + * 1.7 + * The contents of this file are subject to the Mozilla Public License Version 1.8 + * 1.1 (the "License"); you may not use this file except in compliance with 1.9 + * the License. You may obtain a copy of the License at 1.10 + * http://www.mozilla.org/MPL/ 1.11 + * 1.12 + * Software distributed under the License is distributed on an "AS IS" basis, 1.13 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 1.14 + * for the specific language governing rights and limitations under the 1.15 + * License. 1.16 + * 1.17 + * The Initial Developers of the Original Code are Kevin Hendricks (MySpell) 1.18 + * and László Németh (Hunspell). Portions created by the Initial Developers 1.19 + * are Copyright (C) 2002-2005 the Initial Developers. All Rights Reserved. 1.20 + * 1.21 + * Contributor(s): Kevin Hendricks (kevin.hendricks@sympatico.ca) 1.22 + * David Einstein (deinst@world.std.com) 1.23 + * László Németh (nemethl@gyorsposta.hu) 1.24 + * Caolan McNamara (caolanm@redhat.com) 1.25 + * Davide Prina 1.26 + * Giuseppe Modugno 1.27 + * Gianluca Turconi 1.28 + * Simon Brouwer 1.29 + * Noll Janos 1.30 + * Biro Arpad 1.31 + * Goldman Eleonora 1.32 + * Sarlos Tamas 1.33 + * Bencsath Boldizsar 1.34 + * Halacsy Peter 1.35 + * Dvornik Laszlo 1.36 + * Gefferth Andras 1.37 + * Nagy Viktor 1.38 + * Varga Daniel 1.39 + * Chris Halls 1.40 + * Rene Engelhard 1.41 + * Bram Moolenaar 1.42 + * Dafydd Jones 1.43 + * Harri Pitkanen 1.44 + * Andras Timar 1.45 + * Tor Lillqvist 1.46 + * 1.47 + * Alternatively, the contents of this file may be used under the terms of 1.48 + * either the GNU General Public License Version 2 or later (the "GPL"), or 1.49 + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 1.50 + * in which case the provisions of the GPL or the LGPL are applicable instead 1.51 + * of those above. If you wish to allow use of your version of this file only 1.52 + * under the terms of either the GPL or the LGPL, and not to allow others to 1.53 + * use your version of this file under the terms of the MPL, indicate your 1.54 + * decision by deleting the provisions above and replace them with the notice 1.55 + * and other provisions required by the GPL or the LGPL. If you do not delete 1.56 + * the provisions above, a recipient may use your version of this file under 1.57 + * the terms of any one of the MPL, the GPL or the LGPL. 1.58 + * 1.59 + ******* END LICENSE BLOCK *******/ 1.60 + 1.61 +#ifndef _HASHMGR_HXX_ 1.62 +#define _HASHMGR_HXX_ 1.63 + 1.64 +#include "hunvisapi.h" 1.65 + 1.66 +#include <stdio.h> 1.67 + 1.68 +#include "htypes.hxx" 1.69 +#include "filemgr.hxx" 1.70 + 1.71 +enum flag { FLAG_CHAR, FLAG_LONG, FLAG_NUM, FLAG_UNI }; 1.72 + 1.73 +class LIBHUNSPELL_DLL_EXPORTED HashMgr 1.74 +{ 1.75 + int tablesize; 1.76 + struct hentry ** tableptr; 1.77 + int userword; 1.78 + flag flag_mode; 1.79 + int complexprefixes; 1.80 + int utf8; 1.81 + unsigned short forbiddenword; 1.82 + int langnum; 1.83 + char * enc; 1.84 + char * lang; 1.85 + struct cs_info * csconv; 1.86 + char * ignorechars; 1.87 + unsigned short * ignorechars_utf16; 1.88 + int ignorechars_utf16_len; 1.89 + int numaliasf; // flag vector `compression' with aliases 1.90 + unsigned short ** aliasf; 1.91 + unsigned short * aliasflen; 1.92 + int numaliasm; // morphological desciption `compression' with aliases 1.93 + char ** aliasm; 1.94 + 1.95 + 1.96 +public: 1.97 + HashMgr(const char * tpath, const char * apath, const char * key = NULL); 1.98 + ~HashMgr(); 1.99 + 1.100 + struct hentry * lookup(const char *) const; 1.101 + int hash(const char *) const; 1.102 + struct hentry * walk_hashtable(int & col, struct hentry * hp) const; 1.103 + 1.104 + int add(const char * word); 1.105 + int add_with_affix(const char * word, const char * pattern); 1.106 + int remove(const char * word); 1.107 + int decode_flags(unsigned short ** result, char * flags, FileMgr * af); 1.108 + unsigned short decode_flag(const char * flag); 1.109 + char * encode_flag(unsigned short flag); 1.110 + int is_aliasf(); 1.111 + int get_aliasf(int index, unsigned short ** fvec, FileMgr * af); 1.112 + int is_aliasm(); 1.113 + char * get_aliasm(int index); 1.114 + 1.115 +private: 1.116 + int get_clen_and_captype(const char * word, int wbl, int * captype); 1.117 + int load_tables(const char * tpath, const char * key); 1.118 + int add_word(const char * word, int wbl, int wcl, unsigned short * ap, 1.119 + int al, const char * desc, bool onlyupcase); 1.120 + int load_config(const char * affpath, const char * key); 1.121 + int parse_aliasf(char * line, FileMgr * af); 1.122 + int add_hidden_capitalized_word(char * word, int wbl, int wcl, 1.123 + unsigned short * flags, int al, char * dp, int captype); 1.124 + int parse_aliasm(char * line, FileMgr * af); 1.125 + int remove_forbidden_flag(const char * word); 1.126 + 1.127 +}; 1.128 + 1.129 +#endif