diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-05-31 20:16:23 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-05-31 20:16:23 +0200 |
commit | e297fb92c2c0e344d36e0aef57921f6b9b921a61 (patch) | |
tree | ab36c3a121f3f132235ed3eafb5eb5d767c77b3b /common/domainadaptor.cpp | |
parent | 0815156ef93cb9f48073a777b888ed47b579d695 (diff) | |
download | sink-e297fb92c2c0e344d36e0aef57921f6b9b921a61.tar.gz sink-e297fb92c2c0e344d36e0aef57921f6b9b921a61.zip |
Moved default read/write property mapper to TypeImplementation
There is always exactly one default buffer that we can centralize
in TypeImplementation.
Diffstat (limited to 'common/domainadaptor.cpp')
-rw-r--r-- | common/domainadaptor.cpp | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/common/domainadaptor.cpp b/common/domainadaptor.cpp index 8a4b5ed..2955cab 100644 --- a/common/domainadaptor.cpp +++ b/common/domainadaptor.cpp | |||
@@ -19,48 +19,3 @@ | |||
19 | 19 | ||
20 | #include "domainadaptor.h" | 20 | #include "domainadaptor.h" |
21 | 21 | ||
22 | template <> | ||
23 | flatbuffers::uoffset_t variantToProperty<QString>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | ||
24 | { | ||
25 | if (property.isValid()) { | ||
26 | return fbb.CreateString(property.toString().toStdString()).o; | ||
27 | } | ||
28 | return 0; | ||
29 | } | ||
30 | |||
31 | template <> | ||
32 | QVariant propertyToVariant<QString>(const flatbuffers::String *property) | ||
33 | { | ||
34 | if (property) { | ||
35 | return QString::fromStdString(property->c_str()); | ||
36 | } | ||
37 | return QVariant(); | ||
38 | } | ||
39 | |||
40 | template <> | ||
41 | QSharedPointer<ReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> > initializeReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event>() | ||
42 | { | ||
43 | auto propertyMapper = QSharedPointer<ReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> >::create(); | ||
44 | propertyMapper->addMapping("summary", [](Akonadi2::ApplicationDomain::Buffer::Event const *buffer) -> QVariant { | ||
45 | return propertyToVariant<QString>(buffer->summary()); | ||
46 | }); | ||
47 | propertyMapper->addMapping("uid", [](Akonadi2::ApplicationDomain::Buffer::Event const *buffer) -> QVariant { | ||
48 | return propertyToVariant<QString>(buffer->uid()); | ||
49 | }); | ||
50 | return propertyMapper; | ||
51 | } | ||
52 | |||
53 | template <> | ||
54 | QSharedPointer<WritePropertyMapper<Akonadi2::ApplicationDomain::Buffer::EventBuilder> > initializeWritePropertyMapper<Akonadi2::ApplicationDomain::Buffer::EventBuilder>() | ||
55 | { | ||
56 | auto propertyMapper = QSharedPointer<WritePropertyMapper<Akonadi2::ApplicationDomain::Buffer::EventBuilder> >::create(); | ||
57 | propertyMapper->addMapping("summary", [](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(Akonadi2::ApplicationDomain::Buffer::EventBuilder &)> { | ||
58 | auto offset = variantToProperty<QString>(value, fbb); | ||
59 | return [offset](Akonadi2::ApplicationDomain::Buffer::EventBuilder &builder) { builder.add_summary(offset); }; | ||
60 | }); | ||
61 | propertyMapper->addMapping("uid", [](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(Akonadi2::ApplicationDomain::Buffer::EventBuilder &)> { | ||
62 | auto offset = variantToProperty<QString>(value, fbb); | ||
63 | return [offset](Akonadi2::ApplicationDomain::Buffer::EventBuilder &builder) { builder.add_uid(offset); }; | ||
64 | }); | ||
65 | return propertyMapper; | ||
66 | } | ||