kpresenter

ATFInterpreter.h

00001 // -*- Mode: c++-mode; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
00002 /* This file is part of the KDE project
00003    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef ATFINTERP_H
00022 #define ATFINTERP_H
00023 
00024 #include <qpointarray.h>
00025 #include <qptrlist.h>
00026 #include <qstringlist.h>
00027 
00028 class ATFInterpreter {
00029 
00030 public:
00031 
00032     // structure of an attribute list
00033     struct AttribList
00034     {
00035         bool isVariable;
00036         int pwDiv;
00037     };
00038 
00039     // coordinate structure
00040     struct CoordStruct
00041     {
00042         QString a;
00043         QString b;
00044         QString c;
00045         QString d;
00046         QString e;
00047         QString f;
00048         QString result;
00049     };
00050 
00051     // attribute structure
00052     struct AttribStruct
00053     {
00054         QString isVariable;
00055         QString pwDiv;
00056     };
00057 
00058     // structure of signs
00059     struct Sign
00060     {
00061         char op;
00062         int num;
00063         char var;
00064         int type;
00065     };
00066 
00067     // structure of values
00068     struct Value
00069     {
00070         QPtrList<Sign> var1;
00071         QPtrList<Sign> var2;
00072         QPtrList<Sign> var3;
00073         QPtrList<Sign> var4;
00074         QPtrList<Sign> var5;
00075         QPtrList<Sign> var6;
00076         QPtrList<Sign> result;
00077     };
00078 
00079     // constructure - destructure
00080     ATFInterpreter();
00081     ~ATFInterpreter();
00082 
00083     // load autoform
00084     void load(const QString &);
00085 
00086     // get pointarray/attribute list/points
00087     QPointArray getPointArray(int,int);
00088     QPtrList<AttribList> getAttribList();
00089 
00090 protected:
00091 
00092     // fields
00093     static const int ST_WIDTH;
00094     static const int ST_HEIGHT;
00095     static const int ST_VARIABLE;
00096     static const int ST_NUMBER;
00097     static const int ST_OPERATOR;
00098 
00099     // operators
00100     static const char OP_EQUAL;
00101     static const char OP_PLUS;
00102     static const char OP_MINUS;
00103     static const char OP_MULT;
00104     static const char OP_DIV;
00105     static const char COMMENT;
00106 
00107     // block (structure) beginnings - ends
00108     static const char PNT_BG[];
00109     static const char X_BG[];
00110     static const char Y_BG[];
00111     static const char ATTR_BG[];
00112     static const char END[];
00113 
00114     // allowed variables
00115     static const char VAR_1;
00116     static const char VAR_2;
00117     static const char VAR_3;
00118     static const char VAR_4;
00119     static const char VAR_5;
00120     static const char VAR_6;
00121     static const char VAR_X;
00122     static const char VAR_Y;
00123     static const char VAR_VARIA;
00124     static const char VAR_PW;
00125     static const char VAR_W;
00126     static const char VAR_H;
00127 
00128     // level (depth) of the syntax
00129     static const int LEVEL_NULL;
00130     static const int LEVEL_POINT;
00131     static const int LEVEL_X;
00132     static const int LEVEL_Y;
00133     static const int LEVEL_ATTR;
00134 
00135     // numbers
00136     static const char NUM_0;
00137     static const char NUM_1;
00138     static const char NUM_2;
00139     static const char NUM_3;
00140     static const char NUM_4;
00141     static const char NUM_5;
00142     static const char NUM_6;
00143     static const char NUM_7;
00144     static const char NUM_8;
00145     static const char NUM_9;
00146 
00147     // structure of coordinates
00148     struct Coord
00149     {
00150         Value pntX;
00151         Value pntY;
00152         bool isVariable;
00153         int pwDiv;
00154     };
00155 
00156     // interpret the code
00157     void interpret();
00158 
00159     // get varaible of a line
00160     QPtrList<Sign> getVar(const QString&);
00161 
00162     // ********** variables **********
00163 
00164     // list of coordinates and pointers to coordinate/sign/value
00165     QPtrList<Coord> coordList;
00166     QPtrList<AttribList> attrLs;
00167     Coord *coordPtr;
00168     Sign *signPtr;
00169     Value *valuePtr;
00170 
00171     // list of lines
00172     QStringList lines;
00173 };
00174 
00175 #endif //ATFINTERP_H
KDE Home | KDE Accessibility Home | Description of Access Keys