1 /**********************************************************
2  * Version $Id$
3  *********************************************************/
4 #ifndef __BASISTYPEN_H
5 #define __BASISTYPEN_H
6 
7 #include <vector>
8 #include <list>
9 #include <string>
10 #include "grid_bsl.h"
11 #include "MLB_Interface.h"
12 //#include "grid.h"
13 //#include "Parameters.h"
14 
15 
16 #pragma warning (disable : 4786 )
17 
18 extern int FehlerZeile;
19 extern std::string FehlerString;
20 extern int FehlerPos1;
21 extern int FehlerPos2;
22 extern bool isSyntaxCheck;
23 
24 class BBFehlerException
25 {
26 public:
BBFehlerException()27 	BBFehlerException()
28 	{
29 		FehlerPos1 = 0;
30 		FehlerPos2 = 0;
31 	};
32 
33 	BBFehlerException(int z, int p1 = 0, int p2 = 0)
34 	{
35 		FehlerPos1 = p1;
36 		FehlerPos2 = p2;
37 	};
38 };
39 
40 struct T_Point
41 {
42 	long x;
43 	long y;
44 };
45 
46 class BBTyp
47 {
48 public:
49 	std::string name;
50 	enum T_type {IType, FType, PType, MType} type;
51 
BBTyp()52 	BBTyp() {};
~BBTyp()53 	virtual ~BBTyp() {};
54 };
55 
56 class BBInteger : public BBTyp
57 {
58 public:
BBInteger()59 	BBInteger()
60 	{
61 		type = IType;
62 		isMem = true;
63 		i = new long;
64 		*i = 0;
65 	};
66 
BBInteger(int ii)67 	BBInteger(int ii)
68 	{
69 		type = IType;
70 		isMem = true;
71 		i = new long;
72 		*i = ii;
73 	};
74 
BBInteger(long * ii)75 	BBInteger(long *ii)
76 	{
77 		type = IType;
78 		isMem = false;
79 		i = ii;
80 	};
~BBInteger()81 	~BBInteger()
82 	{
83 		if (isMem)
84 			delete i;
85 	};
86 
87 	// z.B. M.xanz auch ein int ist und *i auch darauf zeigen soll
88 	bool isMem;
89 	long *i;
90 };
91 
92 class BBFloat : public BBTyp
93 {
94 public:
BBFloat()95 	BBFloat()
96 	{
97 		type = FType;
98 		isMem = true;
99 		f = new double;
100 		*f = 0.0;
101 	};
102 
BBFloat(double ff)103 	BBFloat(double ff)
104 	{
105 		type = FType;
106 		isMem = true;
107 		f = new double;
108 		*f = ff;
109 	};
110 
BBFloat(double * ff)111 	BBFloat(double *ff)
112 	{
113 		type = FType;
114 		isMem = false;
115 		f = ff;
116 	};
117 
~BBFloat()118 	~BBFloat()
119 	{
120 		if (isMem)
121 			delete f;
122 	};
123 
124 	// Datenelement ist nur ein Pointer, da
125 	// z.B. M.dxy auch ein double ist und *f auch darauf zeigen soll
126 	bool isMem;
127 	double *f;
128 };
129 
130 
131 class BBPoint : public BBTyp
132 {
133 public:
BBPoint()134 	BBPoint()
135 	{
136 		type = PType;
137 	};
138 
BBPoint(const T_Point & vv)139 	BBPoint(const T_Point& vv) : v(vv)
140 	{
141 		type = PType;
142 	};
143 
~BBPoint()144 	~BBPoint() { };
145 
146 	T_Point v;
147 };
148 
149 
150 class BBMatrix : public BBTyp
151 {
152 public:
BBMatrix()153 	BBMatrix()
154 	{
155 		type = MType;
156 		isMem = true;
157 		M = new GridWerte;
158 	};
159 
BBMatrix(GridWerte * m)160 	BBMatrix(GridWerte *m)
161 	{
162 		type = MType;
163 		isMem = false;
164 		M = m;
165 
166 	};
167 
~BBMatrix()168 	~BBMatrix()
169 	{
170 		if (isMem)
171 			delete M;
172 	};
173 
174 	bool isMem;
175 	GridWerte *M;
176 };
177 
178 
179 // Liste aller Variablen
180 typedef std::list<BBTyp *> T_VarList;
181 typedef std::vector<std::string> T_InputText;
182 
183 extern T_VarList Varlist;
184 extern T_InputText InputText;
185 extern T_InputText InputGrids;
186 void DeleteVarList(void);
187 
188 
189 void WhiteSpace(std::string& s, int& pos, bool vorn = true);
190 void trim(std::string& s);
191 bool isNextToken(int zeile, int pos, std::string& cmp);
192 bool isNextChar(int zeile, int pos, const char c);
193 bool getNextToken(int &zeile, int& pos, std::string& erg);
194 bool getNextZeile(int &zeile, int& pos, std::string& erg);
195 bool getNextChar(int& zeile, int& pos, char& c);
196 bool isNotEnd(int& zeile, int& pos, std::string& s);
197 
198 
199 
200 
201 
202 
203 // wandelt Strings in Variablen um (aus InputText wird VarList)
204 void ParseVars(int& zeile, int& pos);
205 
206 // �berpr�ft, ob string eine g�ltige Variable ist
207 BBTyp *isVar(const std::string& s);
208 
209 // ermittelt den Variablen-Typ einer Variablen
210 BBTyp::T_type getVarType(BBTyp *s);
211 
212 // liefert die jeweilige Variable zur�ck
213 BBInteger *getVarI(BBTyp *s);
214 BBFloat *getVarF(BBTyp *s);
215 BBMatrix *getVarM(BBTyp *s);
216 BBPoint *getVarP(BBTyp *s);
217 
218 bool GetMemoryGrids(CSG_Parameters *BSLParameters);
219 bool FindMemoryGrids(void);
220 void AddMatrixPointVariables(bool pointer2matrix);
221 
222 #endif
223