ScummVM API documentation
textsplit.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 GRIM_TEXTSPLIT_HH
23
#define GRIM_TEXTSPLIT_HH
24
25
namespace
Common
{
26
class
SeekableReadStream;
27
}
28
29
namespace
Grim
{
30
31
// A utility class to help in parsing the text-format files. Splits
32
// the text data into lines, skipping comments, trailing whitespace,
33
// and empty lines. Also folds everything to lowercase.
34
35
class
TextSplitter
{
36
public
:
37
TextSplitter
(
const
Common::String
&fname,
Common::SeekableReadStream
*data);
38
~
TextSplitter
();
39
40
char
*nextLine() {
41
processLine();
42
return
_currLine;
43
}
44
45
char
*getCurrentLine() {
return
_currLine; }
46
const
char
*getCurrentLine()
const
{
return
_currLine; }
47
bool
isEof()
const
{
return
_lineIndex == _numLines; }
48
int
getLineNumber() {
return
_lineIndex; }
49
void
setLineNumber(
int
line) { _lineIndex = line - 1; processLine(); }
50
51
// Check if the current line contains 'needle'
52
bool
checkString(
const
char
*needle);
53
54
// Expect a certain fixed string; bail out with an error if not
55
// found. Advance to the next line.
56
void
expectString(
const
char
*expected);
57
58
// Scan a line according to the given format (compatible with
59
// scanf); if not all fields are read (according to the field_count
60
// argument), bail out with an error. Advance to the next line.
61
void
scanString(
const
char
*fmt,
int
field_count, ...);
62
63
// Scan a line starting at offset 'offset' according to the given format
64
// (compatible with scanf); if not all fields are read (according to the
65
// field_count argument), bail out with an error. Advance to the next line.
66
void
scanStringAtOffset(
int
offset,
const
char
*fmt,
int
field_count, ...);
67
68
// Just like scanString(), but without advancing to the next line.
69
void
scanStringNoNewLine(
const
char
*fmt,
int
field_count, ...);
70
71
// Just like scanStringAtOffset(), but without advancing to the next line.
72
void
scanStringAtOffsetNoNewLine(
int
offset,
const
char
*fmt,
int
field_count, ...);
73
74
private
:
75
Common::String
_fname;
76
char
*_stringData;
77
char
*_currLine;
78
int
_numLines, _lineIndex;
79
char
**_lines;
80
81
void
processLine();
82
};
83
84
}
// end of namespace Grim
85
86
#endif
Common::String
Definition:
str.h:59
Common::SeekableReadStream
Definition:
stream.h:745
Grim
Definition:
actor.h:33
Common
Definition:
algorithm.h:29
Grim::TextSplitter
Definition:
textsplit.h:35
engines
grim
textsplit.h
Generated on Sat Nov 23 2024 09:11:53 for ScummVM API documentation by
1.8.13