]> git.lyx.org Git - features.git/blob - 3rdparty/hunspell/1.7.0/src/parsers/textparser.hxx
Update the in-source hunspell to version 1.7.0
[features.git] / 3rdparty / hunspell / 1.7.0 / src / parsers / textparser.hxx
1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * Copyright (C) 2002-2017 Németh László
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks.
17  *
18  * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno,
19  * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád,
20  * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter,
21  * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls,
22  * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen
23  *
24  * Alternatively, the contents of this file may be used under the terms of
25  * either the GNU General Public License Version 2 or later (the "GPL"), or
26  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27  * in which case the provisions of the GPL or the LGPL are applicable instead
28  * of those above. If you wish to allow use of your version of this file only
29  * under the terms of either the GPL or the LGPL, and not to allow others to
30  * use your version of this file under the terms of the MPL, indicate your
31  * decision by deleting the provisions above and replace them with the notice
32  * and other provisions required by the GPL or the LGPL. If you do not delete
33  * the provisions above, a recipient may use your version of this file under
34  * the terms of any one of the MPL, the GPL or the LGPL.
35  *
36  * ***** END LICENSE BLOCK ***** */
37
38 #ifndef TEXTPARSER_HXX_
39 #define TEXTPARSER_HXX_
40
41 // set sum of actual and previous lines
42 #define MAXPREVLINE 4
43
44 #ifndef MAXLNLEN
45 #define MAXLNLEN 8192
46 #endif
47
48 #include "../hunspell/w_char.hxx"
49
50 #include <vector>
51
52 /*
53  * Base Text Parser
54  *
55  */
56
57 class TextParser {
58  protected:
59   std::vector<int> wordcharacters;// for detection of the word boundaries
60   std::string line[MAXPREVLINE];  // parsed and previous lines
61   std::vector<bool> urlline;      // mask for url detection
62   int checkurl;
63   int actual;  // actual line
64   size_t head; // head position
65   size_t token;// begin of token
66   int state;   // state of automata
67   int utf8;    // UTF-8 character encoding
68   int next_char(const char* line, size_t* pos);
69   const w_char* wordchars_utf16;
70   int wclen;
71
72  public:
73   TextParser(const w_char* wordchars, int len);
74   explicit TextParser(const char* wc);
75   virtual ~TextParser();
76
77   void put_line(const char* line);
78   std::string get_line() const;
79   std::string get_prevline(int n) const;
80   virtual bool next_token(std::string&);
81   virtual std::string get_word(const std::string &tok);
82   virtual int change_token(const char* word);
83   void set_url_checking(int check);
84
85   size_t get_tokenpos();
86   int is_wordchar(const char* w);
87   inline int is_utf8() { return utf8; }
88   const char* get_latin1(const char* s);
89   char* next_char();
90   int tokenize_urls();
91   void check_urls();
92   int get_url(size_t token_pos, size_t* head);
93   bool alloc_token(size_t token, size_t* head, std::string& out);
94 private:
95   void init(const char*);
96   void init(const w_char* wordchars, int len);
97 };
98
99 #endif