-
Notifications
You must be signed in to change notification settings - Fork 2
/
value.h
52 lines (42 loc) · 879 Bytes
/
value.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef CONFIG_VALUE_H
#define CONFIG_VALUE_H
#include <QVariant>
#include <QList>
#include <QString>
#include <QStringList>
#include <QMap>
namespace Config {
class Value {
public:
enum Type {
Null,
Integer,
String,
Map,
List,
Boolean
};
Value();
Value(int v);
Value(const QString &v);
Value(const QMap<QString, Value> &v);
Value(const QList<Value> &v);
Value(bool v);
template<class T> T get() const {
return value.value<T>();
}
Type type() const;
Type listType() const;
bool isNull() const;
void setListType(Type t);
operator QString() const;
QString toString() const;
private:
QVariant value;
Type value_type;
Type list_elements_type;
};
}
Q_DECLARE_METATYPE(Config::Value::Type)
Q_DECLARE_METATYPE(Config::Value)
#endif // CONFIG_VALUE_H