diff options
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 | } | ||