OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
tiki_script.h
1/*
2===========================================================================
3Copyright (C) 2023 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23// tiki_script.h : TIKI script
24
25#pragma once
26
27#define TOKENCOMMENT (';')
28#define TOKENCOMMENT2 ('#')
29#define TOKENEOL ('\n')
30//#define TOKENNULL ('\0')
31#define TOKENSPACE (' ')
32#define TOKENSPECIAL ('$')
33
34#define TIKI_MAXTOKEN 256
35
36#define TIKI_MAXMACROS 48
37
38typedef struct {
39 char name[TIKI_MAXTOKEN];
40 char macro[TIKI_MAXTOKEN];
42
43typedef struct {
44 const char *mark_script_p;
45 qboolean mark_tokenready;
46 char mark_token[TIKI_MAXTOKEN];
48
49#ifdef __cplusplus
50
51class TikiScript
52{
53protected:
54 qboolean error;
55 qboolean tokenready;
56 class TikiScript *include;
57 class TikiScript *parent;
58 char filename[TIKI_MAXTOKEN];
59 const char *script_p;
60 const char *end_p;
61 tiki_macro_t macros[TIKI_MAXMACROS];
62 int nummacros;
63 int line;
64 char token[TIKI_MAXTOKEN];
65 qboolean releaseBuffer;
66 tiki_mark_t mark[64];
67 int mark_pos;
68
69public:
70 char *buffer;
71 int length;
72 char path[MAX_QPATH];
73 static class TikiScript *currentScript;
74
75protected:
76 qboolean AtComment();
77 qboolean AtExtendedComment();
78 qboolean AtCommand();
79 qboolean AtString(qboolean crossline);
80 qboolean ProcessCommand(qboolean crossline);
81 qboolean Completed();
82 qboolean SafeCheckOverflow();
83 void CheckOverflow();
84 void Uninclude();
85 const char *FindMacro(const char *macro);
86 void AddMacro(const char *macro, const char *expansion);
87 qboolean SkipToEOL();
88 void SkipWhiteSpace(qboolean crossline);
89 void SkipNonToken(qboolean crossline);
90 qboolean CommentAvailable(qboolean crossline);
91 void SkipExtendedComment();
92
93public:
94 TikiScript();
95 ~TikiScript();
96
97 void Close();
98 const char *Filename();
99 int GetLineNumber();
100 void Reset();
101 qboolean TokenAvailable(qboolean crossline);
102 void UnGetToken();
103 const char *GetToken(qboolean crossline);
104 const char *GetLine(qboolean crossline);
105 const char *GetAndIgnoreLine(qboolean crossline);
106 const char *GetRaw();
107 const char *GetString(qboolean crossline);
108 qboolean GetSpecific(const char *string);
109 int GetInteger(qboolean crossline);
110 double GetDouble(qboolean crossline);
111 float GetFloat(qboolean crossline);
112 void GetVector(qboolean crossline, float *vec);
113 int LinesInFile();
114 void Parse(char *data, int length, const char *name);
115 qboolean LoadFile(const char *name, qboolean quiet);
116 const char *Token();
117 void MarkPos();
118 void ReturnToMark();
119 void ReplaceLineWithWhitespace(bool deleteFromStartOfLine);
120 void Exclude();
121 const char *GetParentToken();
122};
123
124class TikiSwitchKey
125{
126public:
127 str sKeyName;
128 str sKeyValue;
129 TikiSwitchKey *pNextKey;
130
131 TikiSwitchKey();
132};
133
134class TikiSwitcher
135{
136 TikiSwitchKey *m_pSwitchKeys;
137
138private:
139 TikiSwitchKey *GetSwitchKey(const char *);
140 void RemoveUnwantedSwitchOptions(TikiScript *);
141
142public:
143 TikiSwitcher();
144
145 void AddSwitchKey(const char *, const char *);
146 void ChangeSwitchKey(const char *, const char *);
147 void AddOrChangeSwitchKey(const char *, const char *);
148 str& GetSwitchKeyValue(const char *);
149 void PrecompileTikiScript(TikiScript *);
150};
151
152#endif
Definition script.h:52
Definition tiki_script.h:38
Definition tiki_script.h:43