-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscdefines.h
582 lines (501 loc) · 19 KB
/
scdefines.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
/*!
Copyright 2017-2019, 2021 Maxim Noltmeer ([email protected])
This file is part of Extern Logic Interpreter.
Extern Logic Interpreter is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Extern Logic Interpreter is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Extern Logic Interpreter. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SCDEFINES_H_INCLUDED
#define SCDEFINES_H_INCLUDED
#include <vector>
#define UINT unsigned int
typedef std::vector<std::wstring> (SCRIPTLINES);
typedef void (__stdcall *IMPORTFUNC)(void*);
//êîíñòàíòû, îïèñûâàþùèå ñèñòåìíûå ñîîáùåíèÿ
const wchar_t *INFMSG = L"INFO";
const wchar_t *ERRMSG = L"ERROR";
const wchar_t *WRNMSG = L"WARNING";
const wchar_t *COMPILED = L"End script";
const wchar_t *SCEXIT = L"Used _return()";
const wchar_t *SCEXCEPT = L"Throw exception";
const wchar_t *SCSTP = L"Force stop";
const wchar_t *SCEND = L"Finishing with #end";
const wchar_t *SCNOEND = L"Finishing without #end";
const wchar_t *NOBEGIN = L"Error initialising script - no #begin";
const wchar_t *NOEND = L"Error initialising script - no #end";
const wchar_t *NONAME = L"Script name is not defined";
const wchar_t *ERRNAME = L"Incorrect script name";
const wchar_t *INITERR = L"Variable initialising error";
const wchar_t *SYNTAXERR = L"Syntax error";
const wchar_t *UNKVARNAME = L"Unknown variable";
const wchar_t *VARNAMEERR = L"Incorrect variable name";
const wchar_t *UNKERR = L"Unknown error";
const wchar_t *NUMERR = L"Can't convert to number type";
const wchar_t *STRERR = L"Can't convert to character type";
const wchar_t *LREXPRERR = L"Left and right values of expression is not equal";
const wchar_t *FNNAMERR = L"Unknown function or method";
const wchar_t *FNARGERR = L"Error initialising argument(s) of function or method";
const wchar_t *FNARGCNTERR = L"Wrong count of function arguments";
const wchar_t *PROCNAMERR = L"Unknown procedure";
const wchar_t *PROCARGCNTERR = L"Wrong count of procedure arguments";
const wchar_t *PROCARGERR = L"Error initialising argument(s) of procedure";
const wchar_t *PROCNOCRT = L"Can't create procedure";
const wchar_t *PROCNODEL = L"Can't drop procedure";
const wchar_t *NUMCONSLERR = L"Incorrect operation with number type";
const wchar_t *STRCONSLERR = L"Incorrect operation with character type";
const wchar_t *ILLGLOPER = L"Illegal operation with data type";
const wchar_t *FRGMNTERR = L"Fragment translating error";
const wchar_t *COUNTERR = L"Using negative value in counter";
const wchar_t *OBJINDERR = L"Incorrect index of object in stack";
const wchar_t *OBJNAMEERR = L"Incorrect object name";
const wchar_t *OBJNONE = L"Object not found";
const wchar_t *OBJNOPROP = L"Object doesn't contain selected property";
const wchar_t *OBJNOCRT = L"Can't create object";
const wchar_t *OBJNOCRTNAME = L"Can't compare object name";
const wchar_t *OBJNOCRTPROP = L"Can't compare property name";
const wchar_t *OBJMEMNOTACC = L"Member of object is not accessible";
const wchar_t *OBJNODESTR = L"Can't drop object";
const wchar_t *OBJPROPERR = L"Can't create object property";
const wchar_t *ILLGLOBJOPER = L"Illegal operation with object";
const wchar_t *OBJPROPDUP = L"Duplicate object property initialisation";
const wchar_t *OBJNOCTOR = L"Constructor is not found in object class";
const wchar_t *CLNONE = L"Class not found";
const wchar_t *CLNODESTR = L"Can't drop class";
const wchar_t *CLNOPROP = L"Class doesn't contain selected property";
const wchar_t *CLNOPROPREM = L"Can't drop class property";
const wchar_t *CLDUP = L"Duplicate class initialisation";
const wchar_t *CLPROPDUP = L"Duplicate class property initialisation";
const wchar_t *CLMETHDUP = L"Duplicate class method initialisation";
const wchar_t *CLNOPUBPROP = L"Parent class doesn't contain public properties";
const wchar_t *CLNOPUBMETH = L"Parent class doesn't contain public methods";
const wchar_t *PARAMERR = L"Error while getting parameter from stack";
const wchar_t *SELPRMERR = L"Error in 'select' - constant value";
const wchar_t *NOWHENPRM = L"Error in 'select' - no 'when'";
const wchar_t *NOTHENERR = L"Error in 'when' - no 'then'";
const wchar_t *NOPCCODE = L"Value isn't pretranslated fragment";
const wchar_t *UNKDECR = L"Unknown decoration";
const wchar_t *TRGCRTERR = L"Error while creating trigger";
const wchar_t *TRGREMERR = L"Error while removing trigger";
const wchar_t *TRGRUNERR = L"Error while running trigger";
const wchar_t *UNKTRG = L"Unknown trigger";
const wchar_t *TRGEXST = L"Trigger already exist";
//-------------------------------------------------------------------------------
//îáîçíà÷åíèÿ âíóòðåííèõ òèïîâ äàííûõ
enum {
SCNUM = 1,
SCSTR = 2
};
const wchar_t *FRMTNUM = L"%.3f"; //ïðåäñòàâëåíèå ÷èñëà ïðè âûâîäå â ñòðîêó (òî÷íîñòü ÷èñëà)
const wchar_t *ENDLNSTR = L";"; //ïðèçíàê êîíöà ñòðîêè
const wchar_t *CYCLESEP = L","; //ðàçäåëèòåëü âûðàæåíèé â óñëîâèè öèêëà
const wchar_t *STRCONS = L"^"; //çíàê êîíêàòåíàöèè ñòðîê (çàìåíÿåò ñîáîé + â âûðàæåíèÿõ)
const wchar_t *NUMTYPE = L"num"; //ïðèçíàê ÷èñëîâîãî òèïà
const wchar_t *STRTYPE = L"sym"; //ïðèçíàê ñòðîêîâîãî òèïà
const wchar_t *ERROUT = L"-err-"; //ïðèçíàê îøèáêè (âîçâðàùàåòñÿ èç ñòðîêîâûõ ô-é)
const wchar_t *CSTRF = L"$CSTR[%d]"; //øàáëîí èìåíè êîíñò. ñòðîêè
const wchar_t *CNUMF = L"$CNUM[%d]"; //øàáëîí ³ìåíè ÷èñëîâî¿ êîíñòàíòè
const wchar_t *TMPOBJF = L"%c___%d"; //øàáëîí èìåíè âðåìåííîãî îáúåêòà
const wchar_t *EXTPRMF = L"$GET[%d]"; //øàáëîí èìåíè äëÿ ïåðåìåííîé, ñîäåðæàùåé âõ. ïàðàìåòð
const wchar_t *EXTPRMNM = L"INPRM%d"; //øàáëîí èìåíè ïàðàìåòðà ñòåêà äëÿ õðàíåíèÿ âõ. ïàðàìåòðà
const wchar_t *FRGMARK = L"@"; //ñèìâîë ìåòêè ôðàãìåíòà
const wchar_t *FRGMNTF = L"@%d;"; //øàáëîí èìåíè äëÿ ìàðêåðà ôðàãìåíòà êîäà
const wchar_t *EXTPRMSEPS = L"|"; //ðàçäåëèòåëü ñòðîêè âõîäÿùèõ ïàðàìåòðîâ äëÿ ñêðèïòà
const wchar_t *OBJPROPSEPSTR = L"."; //ñèìâîë-ïðèçíàê ñâîéñòâà îáúåêòà
const wchar_t *OBJPROC = L"procedure"; //èìÿ êàòåãîðèè îáúåêòà äëÿ õðàíåíèÿ ïðîöåäóð
const wchar_t *OBJPROCPRM = L"params"; //èìÿ ñâîéñòâà îáúåêòà äëÿ õðàíåíèÿ ïàðàìåòðîâ ïðîöåäóð
const wchar_t *OBJPROCTXT = L"text"; //èìÿ ñâîéñòâà îáúåêòà äëÿ õðàíåíèÿ òåëà ïðîöåäóð
const wchar_t *CLMETHOD = L"method-private"; //èìÿ êàòåãîðèè îáúåêòà äëÿ õðàíåíèÿ ìåòîäà êëàññà
const wchar_t *CLPROP = L"property-private"; //èìÿ êàòåãîðèè îáúåêòà äëÿ õðàíåíèÿ ñâîéñòâà êëàññà
const wchar_t *CLPUBMETHOD = L"method-public"; //òî æå, íî äëÿ ïóáëè÷íîãî ìåòîäà êëàññà
const wchar_t *CLPUBPROP = L"property-public"; //òî æå, íî äëÿ ïóáëè÷íîãî ñâîéñòâà êëàññà
const wchar_t *DTORSYMB = L"~"; //ñèìâîë ùî ïîçíà÷ຠäåñòðóêòîð
#define STRBUFSTACK 4096 //ìàêñ. ðàçìåð ñòðîêîâîãî áóôåðà äëÿ ýêñïîðòà ñîäåðæèìîãî ñòåêîâ
#define CHARSIZE 4096 //ìàêñèìàëüíàÿ äëèíà ñòðîêîâîãî òèïà â ñêðèïòå
#define NUMSIZE 24 //ìàêñèìàëüíîå êîë-âî ñèìâîëîâ, îïèñûâàþùåå ÷èñëî
#define MAXNAMELEN 32 //ìàêñèìàëüíàÿ äëèíà èìåíè ïåðåìåííîé
#define VARSYM '$' //ïðèçíàê ïåðåìåííîé
#define REFSYM '?' //ïðèçíàê äåêîðàöèè
#define FUNCSYM '_' //ïðèçíàê èìåíè ôóíêöèè
#define OBJSYM '&' //ïðèçíàê èìåíè îáúåêòà
#define PROCSYM ':' //ïðèçíàê èìåíè ïðîöåäóðû
#define STRSYM wchar_t(39) //ïðèçíàê ñòðîêîâîãî òèïà (')
#define OBJPROPSEP '.' //ñèìâîë-ïðèçíàê ñâîéñòâà îáúåêòà
#define NEGNUM '!' //ïðèçíàê îòðèöàòåëüíîãî ÷èñëà
#define ENDLN ';' //ïðèçíàê êîíöà ñòðîêè
#define STRCCONS '^' //çíàê êîíêàòåíàöèè ñòðîê (çàìåíÿåò ñîáîé + â âûðàæåíèÿõ)
#define COMSYM '/' //ñèìâîë êîììåíòàðèÿ
#define EXTPRMSEP '|' //ðàçäåëèòåëü ñòðîêè âõîäÿùèõ ïàðàìåòðîâ äëÿ ñêðèïòà
//-------------------------------------------------------------------------------
//èìåíà ñëóæåáíûõ ïàðàìåòðîâ
const wchar_t *P_IND = L"sCurrentLine"; //èíäåêñ ñòðîêè ñêðèïòà
const wchar_t *P_OBJNAME = L"sObjName"; //èìÿ îáúåêòà ñ êîòîðûì ïðîèçâ. îïåðàöèÿ
const wchar_t *P_PROPNAME = L"sPropName"; //èìÿ ñâîéñòâà îáúåêòà ñ êîòîðûì ïðîèçâ. îïåðàöèÿ
const wchar_t *P_SCRNAME = L"sScrName"; //èìÿ ñêðèïòà
const wchar_t *P_SELECT = L"sSelectVal"; //çíà÷åíèå ïîëó÷åííîå êîíñòðóêöèåé select
//ñòðóêòóðà îïèñûâàþùàÿ àññîöèàöèè ñêðèïòîâûõ ïåðåìåííûõ
//è ýëåìåíòîâ ñòåêîâ èíòåðïðåòàòîðà
struct VARIABLE
{
wchar_t varname[MAXNAMELEN]; //èìÿ ïåðåìåííîé èç ñêðèïòà
UINT type; //òèï ñòåêà: 1 - num, 2 - sym
UINT ind; //èíäåêñ â ñòåêå
bool isfree; //ïðèçíàê òîãî äåéñòâóþùàÿ ïåðåìåííàÿ èëè íåò
};
//-------------------------------------------------------------------------------
//ñòðóêòóðà îïèñûâàþùàÿ ññûëêó
struct REFERENCE
{
wchar_t refname[MAXNAMELEN];
wchar_t refobj[CHARSIZE];
};
//-------------------------------------------------------------------------------
//ñòðóêòóðà ùî îïèñóº òðèãåð
struct TRIGGER
{
wchar_t condition[CHARSIZE]; //$x > 0, &obj.X == 0
wchar_t fragment[CHARSIZE];
};
//-------------------------------------------------------------------------------
//ñòðóêòóðà ó ÿê³é ì³ñòÿòüñÿ íàëàøòóâàííÿ ³íòåðïðåòàòîðà äëÿ çì³íè ðàíòàéì
struct SETTINGS
{
bool ParseNumConst; //ïàðñèòè ÷èñëîâ³ êîíñòàíòè ïåðåä òðàíñëÿö³ºþ ðÿäêà
bool ParseSymConst; //ïàðñèòè ñèìâîëüí³ êîíñòàíòè ïåðåä òðàíñëÿö³ºþ ðÿäêà
bool KeepObjects; //çáåð³ãàòè âì³ñò ñòåêó îá'ºêò³â äî ê³íöÿ ðîáîòè ELI
bool KeepClasses; //çáåð³ãàòè âì³ñò ñòåêó êëàñ³â äî ê³íöÿ ðîáîòè ELI
};
//-------------------------------------------------------------------------------
class VARSTACK
{
public:
inline VARSTACK(){};
inline virtual ~VARSTACK(){ClearStack();}
inline VARIABLE *GetFirstFree(UINT type)
{
for (UINT i = 0; i < stMain.size(); i++)
{
if (stMain[i].isfree && stMain[i].type == type)
return &stMain[i];
}
return NULL;
}
//-------------------------------------------------------------------------------
inline VARIABLE *Get(const wchar_t *varname)
{
for (UINT i = 0; i < stMain.size(); i++)
{
if ((0 == wcscmp(stMain[i].varname, varname)) && !stMain[i].isfree)
return &stMain[i];
}
return NULL;
}
//-------------------------------------------------------------------------------
inline VARIABLE *GetByValue(std::wstring val)
{
for (UINT i = 0; i < stStr.size(); i++)
{
if (stStr.at(i) == val)
{
for (UINT j = 0; j < stMain.size(); j++)
{
if ((stMain[j].ind == i) && (2 == stMain[j].type))
return &stMain[j];
}
}
}
return NULL;
}
//-------------------------------------------------------------------------------
inline VARIABLE *GetByValue(float val)
{
for (UINT i = 0; i < stNum.size(); i++)
{
if (stNum.at(i) == val)
{
for (UINT j = 0; j < stMain.size(); j++)
{
if (stMain.at(j).ind == i)
return &stMain.at(i);
}
}
}
return NULL;
}
//-------------------------------------------------------------------------------
inline bool Add(wchar_t *name, std::wstring val)
{
if (Get(name)) //ýëåìåíò ñ òàêèì èìåíåì åñòü â ñòåêå è íå ñâîáîäåí
return false;
VARIABLE *vfree = GetFirstFree(SCSTR);
if (vfree) //åñòü ñâîáîäíûå ýëåìåíòû íóæíîãî òèïà
{
stStr[vfree->ind] = val;
wcscpy(vfree->varname, name);
vfree->isfree = false;
return true;
}
else
{
VARIABLE var;
stStr.push_back(val);
UINT ind = stStr.size() - 1; //óçíàåì èíäåêñ ýëåìåíòà â ñòåêå
wcscpy(var.varname, name);
var.type = SCSTR;
var.ind = ind;
var.isfree = false;
stMain.push_back(var);
return true;
}
}
//-------------------------------------------------------------------------------
inline bool Add(wchar_t *name, float val)
{
if (Get(name)) //ýëåìåíò ñ òàêèì èìåíåì åñòü â ñòåêå è íå ñâîáîäåí
return false;
VARIABLE *vfree = GetFirstFree(SCNUM);
if (vfree) //åñòü ñâîáîäíûå ýëåìåíòû íóæíîãî òèïà
{
stNum[vfree->ind] = val;
wcscpy(vfree->varname, name);
vfree->isfree = false;
return true;
}
else
{
VARIABLE var;
stNum.push_back(val);
UINT ind = stNum.size() - 1; //óçíàåì èíäåêñ ýëåìåíòà â ñòåêå
wcscpy(var.varname, name);
var.type = SCNUM;
var.ind = ind;
var.isfree = false;
stMain.push_back(var);
return true;
}
}
//-------------------------------------------------------------------------------
inline bool Remove(const wchar_t *name)
{
VARIABLE *var = Get(name);
if (!var)
return false;
else
{
//ïîìå÷àåì ýòîò ýëåìåíò ñòåêà êàê ñâîáîäíûé
var->isfree = true;
return true;
}
}
//-------------------------------------------------------------------------------
inline void ClearStack()
{
stMain.clear();
stNum.clear();
stStr.clear();
}
//-------------------------------------------------------------------------------
inline float GetNumElement(VARIABLE *var){return stNum[var->ind];}
inline void SetNumElement(VARIABLE *var, float val){stNum[var->ind] = val;}
inline std::wstring GetStrElement(VARIABLE *var){return stStr[var->ind];}
inline void SetStrElement(VARIABLE *var, std::wstring val){stStr[var->ind] = val;}
//-------------------------------------------------------------------------------
inline const wchar_t *ShowInString()
{
wchar_t frmt[512];
static std::wstring res;
res = L"";
wchar_t out[4096];
wcscpy(frmt, L"[%d] Stack[%d] %s %s = ");
wcscat(frmt, FRMTNUM);
wcscat(frmt, L"\r\n");
for (UINT i = 0; i < stMain.size(); i++)
{
if (!stMain[i].isfree)
{
if (SCNUM == stMain[i].type)
swprintf(out, frmt,
i,
stMain[i].ind,
NUMTYPE,
stMain[i].varname,
stNum[stMain[i].ind]);
else if (SCSTR == stMain[i].type && !stMain[i].isfree)
swprintf(out, L"[%d] Stack[%d] %s %s = %s\r\n",
i,
stMain[i].ind,
STRTYPE,
stMain[i].varname,
stStr[stMain[i].ind].c_str());
res += out;
}
}
return res.c_str();
}
//-------------------------------------------------------------------------------
private:
std::vector<VARIABLE> stMain;
std::vector<float> stNum;
std::vector<std::wstring> stStr;
};
//-------------------------------------------------------------------------------
//ñòðóêòóðà îïèñûâàþùàÿ ÷àñòü âûðàæåíèÿ (ñèìâîë îïåðàöèè è àðãóìåíò)
//ïðèìåð: "+2" -> arg=2;oper='+'
struct SUBEXP
{
float arg; //çíà÷åíèå àðãóìåíòà
wchar_t oper; //ñèìâîë îïåðàöèè
};
//ñòðóêòóðà õðàíèò ïîçèöèè ñîîòâ äðóã äðóãó îòêðûâàþùåé è çàêðûâàþùåé ñêîáîê
struct SCPOS
{
int oppos; //ïîçèöèÿ îòêðûâàþùåé ñêîáêè
int clpos; //ïîçèöèÿ çàêðûâàþùåé
};
class FRAGMENTCODE
{
private:
SCRIPTLINES fCode;
std::wstring fMark;
bool fGlobal;
public:
FRAGMENTCODE(const wchar_t *mark, SCRIPTLINES *code, bool global)
{
fMark = mark;
fCode = *code;
fGlobal = global;
}
FRAGMENTCODE(){};
inline virtual ~FRAGMENTCODE(){fCode.clear();}
inline void SetMark(const wchar_t *new_mark){fMark += new_mark;}
inline const wchar_t *GetMark(){return fMark.c_str();}
inline void SetGlobal(){fGlobal = true;}
inline void SetLocal(){fGlobal = false;}
inline bool IsGlobal(){return fGlobal;}
inline SCRIPTLINES *GetCode(){return &fCode;};
inline const wchar_t *GetCodeStrings()
{
static String res;
res = "";
for (UINT i = 0; i < fCode.size(); i++)
{res += _wltrim(fCode[i].c_str()); res += L"\r\n";}
return res.c_str();
}
};
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
class FRAGMENTSTACK
{
private:
std::vector<FRAGMENTCODE*> FStack;
inline int GetSize(){return FStack.size();}
inline FRAGMENTCODE *ReadFragments(int ind)
{
if (ind < 0)
throw new Exception("FRAGMENTSTACK::Fragments: Out of bounds!");
else if (ind < FStack.size())
return FStack[ind];
else
throw new Exception("FRAGMENTSTACK::Fragments: Out of bounds!");
}
//-------------------------------------------------------------------------------
public:
FRAGMENTSTACK(){};
inline virtual ~FRAGMENTSTACK(){};
inline void Add(std::wstring frg_str, std::wstring mark, bool global)
{
FRAGMENTCODE *new_frg = new FRAGMENTCODE();
new_frg->SetMark(mark.c_str());
if (global)
new_frg->SetGlobal();
else
new_frg->SetLocal();
StrToListW(new_frg->GetCode(), frg_str, ENDLNSTR, DELIMEND);
FStack.push_back(new_frg);
}
//-------------------------------------------------------------------------------
inline void Remove(std::wstring mark)
{
for (UINT i = 0; i < FStack.size(); i++)
{
if (wcscmp(mark.c_str(), FStack[i]->GetMark()) == 0)
{
delete FStack[i];
FStack[i] = NULL;
FStack.erase(FStack.begin() + i);
}
}
}
//-------------------------------------------------------------------------------
inline SCRIPTLINES *GetFragmentCode(std::wstring mark)
{
for (UINT i = 0; i < FStack.size(); i++)
{
if (wcscmp(mark.c_str(), FStack[i]->GetMark()) == 0)
return FStack[i]->GetCode();
}
return NULL;
}
//-------------------------------------------------------------------------------
inline FRAGMENTCODE *Get(std::wstring mark)
{
for (UINT i = 0; i < FStack.size(); i++)
{
if (wcscmp(mark.c_str(), FStack[i]->GetMark()) == 0)
return FStack[i];
}
return NULL;
}
//-------------------------------------------------------------------------------
void ClearFragments(bool all)
{
if (all)
{
for (UINT i = 0; i < FStack.size(); i++)
{
delete FStack[i];
FStack[i] = NULL;
}
FStack.clear();
}
else
{
for (UINT i = 0; i < FStack.size(); i++)
{
if (!FStack[i]->IsGlobal())
{
delete FStack[i];
FStack[i] = NULL;
FStack.erase(FStack.begin() + i);
}
}
}
}
//-------------------------------------------------------------------------------
inline const wchar_t *ShowInString()
{
wchar_t frmt[512];
static std::wstring res;
res = L"";
for (UINT i = 0; i < FStack.size(); i++)
{
swprintf(frmt, L"[%d] {%s} GLOBAL = %d TEXT = \r\n%s\r\n",
i,
FStack[i]->GetMark(),
(UINT)FStack[i]->IsGlobal(),
FStack[i]->GetCodeStrings());
res += frmt;
}
return res.c_str();
}
//-------------------------------------------------------------------------------
__property FRAGMENTCODE *Fragments[int ind] = {read = ReadFragments};
__property int Count = {read = GetSize};
};
#endif // DEFINES_H_INCLUDED