Debian Codegraph @

unikey/pattern.h

raw
1 // -*- coding:unix; mode:c++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 /*------------------------------------------------------------------------------
3 VnConv: Vietnamese Encoding Converter Library
4 UniKey Project: http://unikey.sourceforge.net
5 Copyleft (C) 1998-2002 Pham Kim Long
6 Contact: [email protected]
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
21 --------------------------------------------------------------------------------*/
22
23 #ifndef __PATTERN_H
24 #define __PATTERN_H
25
26 #if defined(_WIN32)
27 #if defined(UNIKEYHOOK)
28 #define DllInterface __declspec( dllexport )
29 #else
30 #define DllInterface __declspec( dllimport )
31 #endif
32 #else
33 #define DllInterface //not used
34 #endif
35
36 #define MAX_PATTERN_LEN 40
37
38 class DllInterface PatternState
39 {
40 public:
41 char *m_pattern;
42 int m_border[MAX_PATTERN_LEN+1];
43 int m_pos;
44 int m_found;
45 void init(char *pattern);
46 void reset();
47 int foundAtNextChar(char ch); //get next input char, returns 1 if pattern is found.
48 };
49
50 class DllInterface PatternList
51 {
52 public:
53 PatternState *m_patterns;
54 int m_count;
55 void init(char **patterns, int count);
56 int foundAtNextChar(char ch);
57 void reset();
58
59 PatternList() {
60 m_count = 0;
61 m_patterns = 0;
62 }
63
64 ~PatternList()
65 {
66 if (m_patterns)
67 delete [] m_patterns;
68 }
69 };
70
71
72 #endif