1 /* |
1 /* |
2 * ZCinema: Zandronum demo launcher |
2 * ZCinema: Zandronum demo launcher |
3 * Copyright (C) 2013 Santeri Piippo |
3 * Copyright (C) 2013-2015 Teemu Piippo |
4 * |
4 * |
5 * This program is free software: you can redistribute it and/or modify |
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 |
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 |
7 * the Free Software Foundation, either version 3 of the License, or |
8 * (at your option) any later version. |
8 * (at your option) any later version. |
14 * |
14 * |
15 * You should have received a copy of the GNU General Public License |
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/>. |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 */ |
17 */ |
18 |
18 |
19 #ifndef ZCINEMA_CFG_H |
19 #pragma once |
20 #define ZCINEMA_CFG_H |
|
21 |
|
22 // ============================================================================= |
|
23 #include <QString> |
|
24 #include <QVariant> |
20 #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 |
21 |
32 // ========================================================= |
22 // ========================================================= |
33 namespace cfg { |
23 namespace Config |
34 enum Type { |
24 { |
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(); |
25 void reset(); |
57 |
26 QVariant get (const QString& name); |
58 class ConfigAdder { |
27 bool set(const QString& name, const QVariant& value); |
59 public: |
|
60 ConfigAdder (void* ptr, Type type, const char* name, QVariant def); |
|
61 }; |
|
62 }; |
28 }; |
63 |
|
64 #endif // ZCINEMA_CFG_H |
|