ScummVM API documentation
xloader.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 #ifndef WINTERMUTE_X_FILE_LEXER_H
23 #define WINTERMUTE_X_FILE_LEXER_H
24 
25 #include "common/memstream.h"
26 #include "common/scummsys.h"
27 #include "common/str.h"
28 
29 namespace Wintermute {
30 
31 enum TokenType {
32  IDENTIFIER = 0,
33  STRING,
34  UUID,
35  INT,
36  FLOAT,
37  OPEN_BRACES,
38  CLOSE_BRACES,
39  OPEN_PAREN,
40  CLOSE_PAREN,
41  OPEN_ANGLE,
42  CLOSE_ANGLE,
43  OPEN_BRACKET,
44  CLOSE_BRACKET,
45  SEMICOLON,
46  COMMA,
47  DOT,
48  NULL_CHAR,
49  UNKNOWN_TOKEN
50 };
51 
52 struct Token {
53  TokenType _type;
54  Common::String _textVal;
55  int _integerVal;
56  float _floatVal;
57 
58  void pushChar(char c);
59 };
60 
61 class XFileLexer {
62 public:
63  XFileLexer(byte *buffer, uint32 fileSize, bool isText);
64 
65  void advanceToNextToken();
66  void skipTerminator();
67  bool eof();
68  bool tokenIsIdentifier();
69  bool tokenIsIdentifier(const char *val);
70  void advanceOnOpenBraces();
71  bool reachedClosedBraces();
72  TokenType getTypeOfToken();
73  bool tokenIsOfType(TokenType type);
74  int tokenToInt();
75  double tokenToFloat();
76  Common::String tokenToString();
77  uint32 tokenToUint32();
78 
79  void skipObject();
80 
81  float readFloat();
82  int readInt();
83  Common::String readString();
84  uint32 readUint32();
85 
86 private:
87  void nextTokenBinary();
88 
89  Token _tok;
91  int _lineCount;
92  bool _isText;
93  int _integersToRead;
94  int _floatsToRead;
95  bool _expectsTerminator;
96 };
97 
98 } // namespace Wintermute
99 
100 #endif
Definition: xloader.h:61
Definition: str.h:59
Definition: xloader.h:52
Definition: memstream.h:43
Definition: achievements_tables.h:27