src/cfg.h

changeset 20
a5457405cc9b
child 30
6b82f6a3ad53
equal deleted inserted replaced
19:c9b6dd9dd4cd 20:a5457405cc9b
1 /*
2 * ZanDemo: Zandronum demo launcher
3 * Copyright (C) 2013 Santeri Piippo
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef ZANDEMO_CFG_H
20 #define ZANDEMO_CFG_H
21
22 // =============================================================================
23 #include <QString>
24 #include <QVariant>
25 #include <QKeySequence>
26
27 #define CONFIG(T, NAME, DEFAULT) namespace cfg { T NAME = DEFAULT; } \
28 cfg::ConfigAdder zz_ConfigAdder_##NAME (&cfg::NAME, cfg::T##Type, #NAME, DEFAULT);
29
30 #define EXTERN_CONFIG(T, NAME) namespace cfg { extern T NAME; }
31
32 // =========================================================
33 namespace cfg {
34 enum Type {
35 IntType,
36 StringType,
37 FloatType,
38 BoolType,
39 KeySeqType,
40 ListType,
41 MapType,
42 };
43
44 // Type-definitions for the above enum list
45 typedef int Int;
46 typedef QString String;
47 typedef float Float;
48 typedef bool Bool;
49 typedef QKeySequence KeySeq;
50 typedef QList<QVariant> List;
51 typedef QMap<QString, QVariant> Map;
52
53 // ------------------------------------------
54 bool load();
55 bool save();
56 void reset();
57
58 class ConfigAdder {
59 public:
60 ConfigAdder (void* ptr, Type type, const char* name, QVariant def);
61 };
62 };
63
64 #endif // ZANDEMO_CFG_H

mercurial