diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-04 16:40:28 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-04 16:40:28 +0100 |
commit | 46570dd9684990846cfd4c3dc5be71498c5a6278 (patch) | |
tree | 3dc2369059f795f4be2ff6e2bca84db0c5bde749 /common/propertymapper.cpp | |
parent | 983af5f1442ff27dc14da6fdac28f51a38184f0a (diff) | |
download | sink-46570dd9684990846cfd4c3dc5be71498c5a6278.tar.gz sink-46570dd9684990846cfd4c3dc5be71498c5a6278.zip |
example client and properties
Diffstat (limited to 'common/propertymapper.cpp')
-rw-r--r-- | common/propertymapper.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/common/propertymapper.cpp b/common/propertymapper.cpp index 60f7dd5..17a73cb 100644 --- a/common/propertymapper.cpp +++ b/common/propertymapper.cpp | |||
@@ -18,6 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "propertymapper.h" | 20 | #include "propertymapper.h" |
21 | #include <QDateTime> | ||
21 | 22 | ||
22 | template <> | 23 | template <> |
23 | flatbuffers::uoffset_t variantToProperty<QString>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | 24 | flatbuffers::uoffset_t variantToProperty<QString>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) |
@@ -38,6 +39,15 @@ flatbuffers::uoffset_t variantToProperty<QByteArray>(const QVariant &property, f | |||
38 | } | 39 | } |
39 | 40 | ||
40 | template <> | 41 | template <> |
42 | flatbuffers::uoffset_t variantToProperty<QDateTime>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | ||
43 | { | ||
44 | if (property.isValid()) { | ||
45 | return fbb.CreateString(property.toDateTime().toString().toStdString()).o; | ||
46 | } | ||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | template <> | ||
41 | QVariant propertyToVariant<QString>(const flatbuffers::String *property) | 51 | QVariant propertyToVariant<QString>(const flatbuffers::String *property) |
42 | { | 52 | { |
43 | if (property) { | 53 | if (property) { |
@@ -62,3 +72,13 @@ QVariant propertyToVariant<bool>(uint8_t property) | |||
62 | { | 72 | { |
63 | return static_cast<bool>(property); | 73 | return static_cast<bool>(property); |
64 | } | 74 | } |
75 | |||
76 | template <> | ||
77 | QVariant propertyToVariant<QDateTime>(const flatbuffers::String *property) | ||
78 | { | ||
79 | if (property) { | ||
80 | //We have to copy the memory, otherwise it would become eventually invalid | ||
81 | return QDateTime::fromString(QString::fromStdString(property->c_str())); | ||
82 | } | ||
83 | return QVariant(); | ||
84 | } | ||