kpresenter

ATFInterpreter.h
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef ATFINTERP_H
21#define ATFINTERP_H
22
23#include <tqpointarray.h>
24#include <tqptrlist.h>
25#include <tqstringlist.h>
26
27class ATFInterpreter {
28
29public:
30
31 // structure of an attribute list
32 struct AttribList
33 {
34 bool isVariable;
35 int pwDiv;
36 };
37
38 // coordinate structure
39 struct CoordStruct
40 {
41 TQString a;
42 TQString b;
43 TQString c;
44 TQString d;
45 TQString e;
46 TQString f;
47 TQString result;
48 };
49
50 // attribute structure
51 struct AttribStruct
52 {
53 TQString isVariable;
54 TQString pwDiv;
55 };
56
57 // structure of signs
58 struct Sign
59 {
60 char op;
61 int num;
62 char var;
63 int type;
64 };
65
66 // structure of values
67 struct Value
68 {
69 TQPtrList<Sign> var1;
70 TQPtrList<Sign> var2;
71 TQPtrList<Sign> var3;
72 TQPtrList<Sign> var4;
73 TQPtrList<Sign> var5;
74 TQPtrList<Sign> var6;
75 TQPtrList<Sign> result;
76 };
77
78 // constructure - destructure
79 ATFInterpreter();
80 ~ATFInterpreter();
81
82 // load autoform
83 void load(const TQString &);
84
85 // get pointarray/attribute list/points
86 TQPointArray getPointArray(int,int);
87 TQPtrList<AttribList> getAttribList();
88
89protected:
90
91 // fields
92 static const int ST_WIDTH;
93 static const int ST_HEIGHT;
94 static const int ST_VARIABLE;
95 static const int ST_NUMBER;
96 static const int ST_OPERATOR;
97
98 // operators
99 static const char OP_EQUAL;
100 static const char OP_PLUS;
101 static const char OP_MINUS;
102 static const char OP_MULT;
103 static const char OP_DIV;
104 static const char COMMENT;
105
106 // block (structure) beginnings - ends
107 static const char PNT_BG[];
108 static const char X_BG[];
109 static const char Y_BG[];
110 static const char ATTR_BG[];
111 static const char END[];
112
113 // allowed variables
114 static const char VAR_1;
115 static const char VAR_2;
116 static const char VAR_3;
117 static const char VAR_4;
118 static const char VAR_5;
119 static const char VAR_6;
120 static const char VAR_X;
121 static const char VAR_Y;
122 static const char VAR_VARIA;
123 static const char VAR_PW;
124 static const char VAR_W;
125 static const char VAR_H;
126
127 // level (depth) of the syntax
128 static const int LEVEL_NULL;
129 static const int LEVEL_POINT;
130 static const int LEVEL_X;
131 static const int LEVEL_Y;
132 static const int LEVEL_ATTR;
133
134 // numbers
135 static const char NUM_0;
136 static const char NUM_1;
137 static const char NUM_2;
138 static const char NUM_3;
139 static const char NUM_4;
140 static const char NUM_5;
141 static const char NUM_6;
142 static const char NUM_7;
143 static const char NUM_8;
144 static const char NUM_9;
145
146 // structure of coordinates
147 struct Coord
148 {
149 Value pntX;
150 Value pntY;
151 bool isVariable;
152 int pwDiv;
153 };
154
155 // interpret the code
156 void interpret();
157
158 // get varaible of a line
159 TQPtrList<Sign> getVar(const TQString&);
160
161 // ********** variables **********
162
163 // list of coordinates and pointers to coordinate/sign/value
164 TQPtrList<Coord> coordList;
165 TQPtrList<AttribList> attrLs;
166 Coord *coordPtr;
167 Sign *signPtr;
168 Value *valuePtr;
169
170 // list of lines
171 TQStringList lines;
172};
173
174#endif //ATFINTERP_H