-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathqsyncablefunctions.h
72 lines (44 loc) · 2.23 KB
/
qsyncablefunctions.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef QSYNCABLEFUNCTIONS_H
#define QSYNCABLEFUNCTIONS_H
#include <QObject>
#include <QJSValue>
#include <QVariant>
namespace QSyncable {
/// Assign properties from source object to the destination object.
void assign(QVariantMap& dest, const QObject*source);
void assign(QObject* dest, const QVariantMap& source);
void assign(QObject* dest, const QJSValue& source);
/// Gets the value at path of object. If the path is not found, the defaultValue is returned.
/*
Example:
get(object, "a.b.c");
*/
QVariant get(const QObject* source, const QString& path, const QVariant& defaultValue = QVariant());
QVariant get(const QObject* source, const QStringList& path, const QVariant& defaultValue = QVariant());
QVariant get(const QVariantMap& source, const QString& path, const QVariant& defaultValue = QVariant());
QVariant get(const QVariantMap& source, const QStringList& path, const QVariant& defaultValue = QVariant());
/// Sets the value at path of object. If a portion of path doesn't exist, it's created.
/*
Example:
set(data, "a.b", 3); // data["a"] will be a QVariantMap that contains a key of "b".
*/
void set(QVariantMap& dest, const QString& path, const QVariant& value);
void set(QVariantMap& dest, const QStringList& path, const QVariant& value);
/// Creates an QVariantMap composed of the picked object properties at paths.
/*
Example:
pick(object, QStringList() << "a" << "b.c");
If a property contains QObject pointer, it will be converted to QVariantMap.
In case you need to obtain a QObject pointer, please use get().
*/
QVariantMap pick(QObject* source, const QStringList& paths);
QVariantMap pick(QVariantMap source, const QStringList& paths);
QVariantMap pick(QVariantMap source, const QVariantMap& paths);
/// The opposite of pick(), this method creates an QVariantMap composed of the own properties that are not omitted.
/*
If a property contains QObject pointer, it will be converted to QVariantMap.
In case you need to obtain a QObject pointer, please use get().
*/
QVariantMap omit(const QVariantMap& source, const QVariantMap& properties);
}
#endif // QSYNCABLEFUNCTIONS_H