Debian Codegraph @

unikey/mactab.h

raw
1 // -*- coding:unix; mode:c++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 /* Unikey Vietnamese Input Method
3 * Copyright (C) 2000-2005 Pham Kim Long
4 * Contact:
5 * [email protected]
6 * UniKey project: http://unikey.org
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library 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 GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor
21 * Boston, MA 02110-1301, USA.
22 */
23
24 #ifndef __MACRO_TABLE_H
25 #define __MACRO_TABLE_H
26
27 #include "keycons.h"
28 #include "charset.h"
29
30 #if defined(_WIN32)
31 #if defined(UNIKEYHOOK)
32 #define DllInterface __declspec( dllexport )
33 #else
34 #define DllInterface __declspec( dllimport )
35 #endif
36 #else
37 #define DllInterface //not used
38 #define DllExport
39 #define DllImport
40 #endif
41
42 struct MacroDef
43 {
44 int keyOffset;
45 int textOffset;
46 };
47
48 #if !defined(WIN32)
49 typedef char TCHAR;
50 #endif
51
52 class DllInterface CMacroTable
53 {
54 public:
55 void init();
56 int loadFromFile(const char *fname);
57 int writeToFile(const char *fname);
58 int writeToFp(FILE* f);
59
60 const StdVnChar *lookup(StdVnChar *key);
61 const StdVnChar *getKey(int idx) const;
62 const StdVnChar *getText(int idx) const;
63 int getCount() const { return m_count; }
64 void resetContent();
65 int addItem(const char *item, int charset);
66 int addItem(const void *key, const void *text, int charset);
67
68 protected:
69 bool readHeader(FILE *f, int & version);
70 void writeHeader(FILE *f);
71
72 MacroDef m_table[MAX_MACRO_ITEMS];
73 char m_macroMem[MACRO_MEM_SIZE];
74
75 int m_count;
76 int m_memSize, m_occupied;
77 };
78
79 #endif