ScummVM API documentation
nl_parse.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 WATCHMAKER_NL_PARSE_H
23#define WATCHMAKER_NL_PARSE_H
24
25#define J_MAXSTRLEN 512L
26#include "common/stream.h"
27
28namespace Watchmaker {
29
30class NLParser {
31 unsigned int jStringLimit = J_MAXSTRLEN, jTillEOL = 0, jUsingComments = 0;
32 unsigned long nlLineCounter;
33 int ReadArgument_(char *str, int teol);
35 void (*ErrorFunc)() = nullptr;
36public:
37 // TODO: Need a static version that allows for failure, as we have fallbacks in the code to use.
38 static Common::SharedPtr<NLParser> open(const Common::String &name);
40 int ParseError(const char *ln, ...);
41 void IfParseErrorDo(void (*func)());
42 int ReadArgumentEOL(char *str) {
43 return ReadArgument_(str, 1);
44 }
45 int ReadArgument(char *str) {
46 return ReadArgument_(str, 0);
47 }
48 int ReadNumber(); //max 80 cifre
49 int SearchArgument(char *t, ...);
50 int getCurLine() {
51 return nlLineCounter;
52 }
53
54 int JParse_ReadByte(void) {
55 int a = _stream->readByte();
56 if (a == '\n')
57 nlLineCounter++;
58 return a;
59 }
60
61 int JParse_PrevByte(void) {
62
63 if (_stream->seek(-1, SEEK_SET))
64 return 0;
65 return 1;
66 }
67
68 int MatchWord(const char *token);
69
70#define EOF_PARSED -2
71};
72
73
74} // End of namespace Watchmaker
75
76#endif // WATCHMAKER_NL_PARSE_H
byte readByte()
Definition: stream.h:434
virtual bool seek(int64 offset, int whence=SEEK_SET)=0
Definition: str.h:59
Definition: nl_parse.h:30