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  { \
35  TOKEN_NONE = 0,
36 #define TOKEN_DEF(name) \
37  TOKEN_ ## name,
38 #define TOKEN_DEF_END \
39  TOKEN_TOTAL_COUNT \
40  };
41 #define TOKEN_TABLE_START(name) \
42  static const BaseParser::TokenDesc name [] = \
43  {
44 #define TOKEN_TABLE(name) \
45  { TOKEN_ ## name, #name },
46 #define TOKEN_TABLE_END \
47  { 0, 0 } \
48  };
49 
50 #define PARSERR_GENERIC -3
51 #define PARSERR_EOF -2
52 #define PARSERR_TOKENNOTFOUND -1
53 
54 #include "engines/wintermute/coll_templ.h"
55 
56 namespace Wintermute {
57 
58 class BaseParser {
59 public:
60  struct TokenDesc {
61  int32 id;
62  const char *token;
63  };
64 
65 public:
66  int32 scanStr(const char *in, const char *format, ...);
67  int32 getCommand(char **buf, const TokenDesc *tokens, char **params);
68  BaseParser();
69  virtual ~BaseParser();
70 private:
71  char *getLastOffender();
72  void skipToken(char **buf, char *tok, char *msg = nullptr);
73  int32 getTokenInt(char **buf);
74  float getTokenFloat(char **buf);
75  Common::String getToken(char **buf);
76  char *getAssignmentText(char **buf);
77  char *getSubText(char **buf, char open, char close);
78  void skipCharacters(char **buf, const char *toSkip);
79  int32 getObject(char **buf, const TokenDesc *tokens, char **name, char **data);
80  int32 _parserLine = 0;
81  char _lastOffender[255];
82  char *_whiteSpace;
83 };
84 
85 } // End of namespace Wintermute
86 
87 #endif
Definition: str.h:59
Definition: base_parser.h:58
Definition: base_parser.h:60
Definition: achievements_tables.h:27