Freeciv21
Develop your civilization from humble roots to a global empire
inputfile.h
Go to the documentation of this file.
1
/**************************************************************************
2
Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3
__ __ part of Freeciv21. Freeciv21 is free software: you can
4
/ \\..// \ redistribute it and/or modify it under the terms of the GNU
5
( oo ) General Public License as published by the Free Software
6
\__/ Foundation, either version 3 of the License, or (at your
7
option) any later version. You should have received
8
a copy of the GNU General Public License along with Freeciv21. If not,
9
see https://www.gnu.org/licenses/.
10
**************************************************************************/
11
12
/**********************************************************************
13
A low-level object for reading a registry-format file.
14
See comments in inputfile.c
15
***********************************************************************/
16
17
#pragma once
18
19
// utility
20
#include "
support.h
"
// bool type and fc__attribute
21
22
#include <QString>
23
24
class
QIODevice;
25
struct
inputfile
;
// opaque
26
27
using
datafilename_fn_t
= QString (*)(
const
QString &
filename
);
28
29
struct
inputfile
*
inf_from_file
(
const
QString &
filename
,
30
datafilename_fn_t
datafn
);
31
struct
inputfile
*
inf_from_stream
(QIODevice *
stream
,
32
datafilename_fn_t
datafn
);
33
void
inf_close
(
struct
inputfile
*inf);
34
bool
inf_at_eof
(
struct
inputfile
*inf);
35
36
enum
inf_token_type
{
37
INF_TOK_SECTION_NAME
,
38
INF_TOK_ENTRY_NAME
,
39
INF_TOK_EOL
,
40
INF_TOK_TABLE_START
,
41
INF_TOK_TABLE_END
,
42
INF_TOK_COMMA
,
43
INF_TOK_VALUE
,
44
INF_TOK_LAST
45
};
46
#define INF_TOK_FIRST INF_TOK_SECTION_NAME
47
48
QString
inf_token
(
struct
inputfile
*inf,
enum
inf_token_type
type);
49
int
inf_discard_tokens
(
struct
inputfile
*inf,
enum
inf_token_type
type);
50
51
QString
inf_log_str
(
struct
inputfile
*inf,
const
char
*
message
, ...)
52
fc__attribute
((__format__(__printf__, 2, 3)));
inf_from_stream
struct inputfile * inf_from_stream(QIODevice *stream, datafilename_fn_t datafn)
Open the stream, and return an allocated, initialized structure.
Definition:
inputfile.cpp:225
inf_token_type
inf_token_type
Definition:
inputfile.h:36
INF_TOK_EOL
@ INF_TOK_EOL
Definition:
inputfile.h:39
INF_TOK_COMMA
@ INF_TOK_COMMA
Definition:
inputfile.h:42
INF_TOK_TABLE_END
@ INF_TOK_TABLE_END
Definition:
inputfile.h:41
INF_TOK_VALUE
@ INF_TOK_VALUE
Definition:
inputfile.h:43
INF_TOK_TABLE_START
@ INF_TOK_TABLE_START
Definition:
inputfile.h:40
INF_TOK_ENTRY_NAME
@ INF_TOK_ENTRY_NAME
Definition:
inputfile.h:38
INF_TOK_LAST
@ INF_TOK_LAST
Definition:
inputfile.h:44
INF_TOK_SECTION_NAME
@ INF_TOK_SECTION_NAME
Definition:
inputfile.h:37
inf_token
QString inf_token(struct inputfile *inf, enum inf_token_type type)
Returns token of given type from given inputfile.
Definition:
inputfile.cpp:536
inf_log_str
QString inf_log_str(struct inputfile *inf, const char *message,...) fc__attribute((__format__(__printf__
inf_at_eof
bool inf_at_eof(struct inputfile *inf)
Return TRUE if current pos is at end of file.
Definition:
inputfile.cpp:323
inf_close
void inf_close(struct inputfile *inf)
Close the file and free associated memory, included any partially recursed included files,...
Definition:
inputfile.cpp:285
inf_discard_tokens
int inf_discard_tokens(struct inputfile *inf, enum inf_token_type type)
Read as many tokens of specified type as possible, discarding the results; returns number of such tok...
Definition:
inputfile.cpp:563
datafilename_fn_t
QString(*)(const QString &filename) datafilename_fn_t
Definition:
inputfile.h:27
inf_from_file
struct inputfile * inf_from_file(const QString &filename, datafilename_fn_t datafn)
Open the file, and return an allocated, initialized structure.
Definition:
inputfile.cpp:202
inputfile
Definition:
inputfile.cpp:81
inputfile::stream
QTextStream * stream
Definition:
inputfile.cpp:85
inputfile::filename
QString filename
Definition:
inputfile.cpp:83
inputfile::datafn
datafilename_fn_t datafn
Definition:
inputfile.cpp:93
message
Definition:
messagewin_common.h:16
support.h
fc__attribute
int fc__attribute((nonnull(1, 3)))
utility
inputfile.h
Generated by
1.9.1