ScummVM API documentation
base_parser.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22/*
23 * This file is based on WME Lite.
24 * http://dead-code.org/redir.php?target=wmelite
25 * Copyright (c) 2011 Jan Nedoma
26 */
27
28#ifndef WINTERMUTE_BASE_PARSER_H
29#define WINTERMUTE_BASE_PARSER_H
30
31
32#define TOKEN_DEF_START \
33 enum { \
34 TOKEN_NONE = 0,
35#define TOKEN_DEF(name) \
36 TOKEN_ ## name,
37#define TOKEN_DEF_END \
38 TOKEN_TOTAL_COUNT \
39 };
40#define TOKEN_TABLE_START(name) \
41 static const BaseParser::TokenDesc name [] = \
42 {
43#define TOKEN_TABLE(name) \
44 { TOKEN_ ## name, #name },
45#define TOKEN_TABLE_END \
46 { 0, 0 } \
47 };
48
49#define PARSERR_GENERIC -3
50#define PARSERR_EOF -2
51#define PARSERR_TOKENNOTFOUND -1
52
53#include "engines/wintermute/coll_templ.h"
54#include "engines/wintermute/base/base.h"
55
56namespace Wintermute {
57
58class BaseParser : public BaseClass {
59public:
60 struct TokenDesc {
61 int32 id;
62 const char *token;
63 };
64
65public:
66 int32 scanStr(const char *in, const char *format, ...);
67 char *getLastOffender();
68 void skipToken(char **buf, char *tok, char *msg = nullptr);
69 int32 getTokenInt(char **buf);
70 float getTokenFloat(char **buf);
71 char *getToken(char **buf);
72 char *getAssignmentText(char **buf);
73 char *getSubText(char **buf, char open, char close);
74 void skipCharacters(char **buf, const char *toSkip);
75 int32 getCommand(char **buf, const TokenDesc *tokens, char **params);
76 int32 getObject(char **buf, const TokenDesc *tokens, char **name, char **data);
77 int32 _parserLine = 0;
78 char _lastOffender[255];
79 BaseParser(BaseGame *inGame = nullptr);
80 virtual ~BaseParser();
81 char *_whiteSpace;
82};
83
84} // End of namespace Wintermute
85
86#endif
Definition: base.h:43
Definition: base_game.h:79
Definition: base_parser.h:58
Definition: base_parser.h:60