~ubuntu-branches/ubuntu/vivid/robojournal/vivid-proposed

« back to all changes in this revision

Viewing changes to ui/hunspell/hashmgr.hxx

  • Committer: Package Import Robot
  • Author(s): Ritesh Raj Sarraf
  • Date: 2014-10-14 15:50:21 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20141014155021-gjd34w00cquge8jf
Tags: 0.5-1
* [d7ce610] Imported Upstream version 0.5
* [ff3b609] Refine what is in the docs/
* [c1e0474] Add doc-base registration
* [68cd341] Install upstream provided xpm icon
* [a627af4] Add patch to override hardcoded doc location

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    This file is part of RoboJournal.
3
 
    Copyright (c) 2013 by Will Kraft <pwizard@gmail.com>.
4
 
    MADE IN USA
5
 
 
6
 
    RoboJournal is free software: you can redistribute it and/or modify
7
 
    it under the terms of the GNU General Public License as published by
8
 
    the Free Software Foundation, either version 3 of the License, or
9
 
    (at your option) any later version.
10
 
 
11
 
    RoboJournal is distributed in the hope that it will be useful,
12
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
    GNU General Public License for more details.
15
 
 
16
 
    You should have received a copy of the GNU General Public License
17
 
    along with RoboJournal.  If not, see <http://www.gnu.org/licenses/>.
18
 
  */
19
 
 
20
 
/* ***** BEGIN LICENSE BLOCK *****
21
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
22
 
 *
23
 
 * The contents of this file are subject to the Mozilla Public License Version
24
 
 * 1.1 (the "License"); you may not use this file except in compliance with
25
 
 * the License. You may obtain a copy of the License at
26
 
 * http://www.mozilla.org/MPL/
27
 
 *
28
 
 * Software distributed under the License is distributed on an "AS IS" basis,
29
 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
30
 
 * for the specific language governing rights and limitations under the
31
 
 * License.
32
 
 *
33
 
 * The Original Code is Hunspell, based on MySpell.
34
 
 *
35
 
 * The Initial Developers of the Original Code are
36
 
 * Kevin Hendricks (MySpell) and Laszlo Nemeth (Hunspell).
37
 
 * Portions created by the Initial Developers are Copyright (C) 2002-2005
38
 
 * the Initial Developers. All Rights Reserved.
39
 
 *
40
 
 * Contributor(s):
41
 
 * David Einstein
42
 
 * Davide Prina
43
 
 * Giuseppe Modugno
44
 
 * Gianluca Turconi
45
 
 * Simon Brouwer
46
 
 * Noll Janos
47
 
 * Biro Arpad
48
 
 * Goldman Eleonora
49
 
 * Sarlos Tamas
50
 
 * Bencsath Boldizsar
51
 
 * Halacsy Peter
52
 
 * Dvornik Laszlo
53
 
 * Gefferth Andras
54
 
 * Nagy Viktor
55
 
 * Varga Daniel
56
 
 * Chris Halls
57
 
 * Rene Engelhard
58
 
 * Bram Moolenaar
59
 
 * Dafydd Jones
60
 
 * Harri Pitkanen
61
 
 * Andras Timar
62
 
 * Tor Lillqvist
63
 
 *
64
 
 * Alternatively, the contents of this file may be used under the terms of
65
 
 * either the GNU General Public License Version 2 or later (the "GPL"), or
66
 
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
67
 
 * in which case the provisions of the GPL or the LGPL are applicable instead
68
 
 * of those above. If you wish to allow use of your version of this file only
69
 
 * under the terms of either the GPL or the LGPL, and not to allow others to
70
 
 * use your version of this file under the terms of the MPL, indicate your
71
 
 * decision by deleting the provisions above and replace them with the notice
72
 
 * and other provisions required by the GPL or the LGPL. If you do not delete
73
 
 * the provisions above, a recipient may use your version of this file under
74
 
 * the terms of any one of the MPL, the GPL or the LGPL.
75
 
 *
76
 
 * ***** END LICENSE BLOCK ***** */
77
 
 
78
 
#ifndef _HASHMGR_HXX_
79
 
#define _HASHMGR_HXX_
80
 
 
81
 
#ifndef MOZILLA_CLIENT
82
 
#include <cstdio>
83
 
#else
84
 
#include <stdio.h>
85
 
#endif
86
 
 
87
 
#include "ui/hunspell/htypes.hxx"
88
 
#include "ui/hunspell/filemgr.hxx"
89
 
 
90
 
enum flag { FLAG_CHAR, FLAG_LONG, FLAG_NUM, FLAG_UNI };
91
 
 
92
 
class HashMgr
93
 
{
94
 
  int             tablesize;
95
 
  struct hentry ** tableptr;
96
 
  int             userword;
97
 
  flag            flag_mode;
98
 
  int             complexprefixes;
99
 
  int             utf8;
100
 
  unsigned short  forbiddenword;
101
 
  int             langnum;
102
 
  char *          enc;
103
 
  char *          lang;
104
 
  struct cs_info * csconv;
105
 
  char *          ignorechars;
106
 
  unsigned short * ignorechars_utf16;
107
 
  int             ignorechars_utf16_len;
108
 
  int                 numaliasf; // flag vector `compression' with aliases
109
 
  unsigned short **   aliasf;
110
 
  unsigned short *    aliasflen;
111
 
  int                 numaliasm; // morphological desciption `compression' with aliases
112
 
  char **             aliasm;
113
 
 
114
 
 
115
 
public:
116
 
  HashMgr(const char * tpath, const char * apath, const char * key = NULL);
117
 
  ~HashMgr();
118
 
 
119
 
  struct hentry * lookup(const char *) const;
120
 
  int hash(const char *) const;
121
 
  struct hentry * walk_hashtable(int & col, struct hentry * hp) const;
122
 
 
123
 
  int add(const char * word, char * aff);
124
 
  int add_with_affix(const char * word, const char * pattern);
125
 
  int remove(const char * word);
126
 
  int decode_flags(unsigned short ** result, char * flags);
127
 
  unsigned short        decode_flag(const char * flag);
128
 
  char *                encode_flag(unsigned short flag);
129
 
  int is_aliasf();
130
 
  int get_aliasf(int index, unsigned short ** fvec);
131
 
  int is_aliasm();
132
 
  char * get_aliasm(int index);
133
 
  
134
 
private:
135
 
  int get_clen_and_captype(const char * word, int wbl, int * captype);
136
 
  int load_tables(const char * tpath, const char * key);
137
 
  int add_word(const char * word, int wbl, int wcl, unsigned short * ap,
138
 
    int al, const char * desc, bool onlyupcase);
139
 
  int load_config(const char * affpath, const char * key);
140
 
  int parse_aliasf(char * line, FileMgr * af);
141
 
  int add_hidden_capitalized_word(char * word, int wbl, int wcl,
142
 
    unsigned short * flags, int al, char * dp, int captype);
143
 
  int parse_aliasm(char * line, FileMgr * af);
144
 
  int remove_forbidden_flag(const char * word);
145
 
 
146
 
};
147
 
 
148
 
#endif