summaryrefslogtreecommitdiffstats
path: root/common/domainadaptor.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-12 16:02:10 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-12 16:02:10 +0200
commite85967518b9041e9943ec5f1765c6694bb153840 (patch)
tree0f4c8a87a0788c67fbe7c11414c0d96a7f863d11 /common/domainadaptor.cpp
parentea348c62fdebe1d9c6531fc4491d3316a1e941df (diff)
downloadsink-e85967518b9041e9943ec5f1765c6694bb153840.tar.gz
sink-e85967518b9041e9943ec5f1765c6694bb153840.zip
More generic domainadpator code.
This should cover read and write for entites that have a 1:1 mapping to the resource buffers.
Diffstat (limited to 'common/domainadaptor.cpp')
-rw-r--r--common/domainadaptor.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/common/domainadaptor.cpp b/common/domainadaptor.cpp
index 5e6f062..aa8c3d9 100644
--- a/common/domainadaptor.cpp
+++ b/common/domainadaptor.cpp
@@ -20,6 +20,15 @@
20#include "domainadaptor.h" 20#include "domainadaptor.h"
21 21
22template <> 22template <>
23flatbuffers::uoffset_t extractProperty<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
31template <>
23QSharedPointer<ReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> > initializeReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event>() 32QSharedPointer<ReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> > initializeReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event>()
24{ 33{
25 auto propertyMapper = QSharedPointer<ReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> >::create(); 34 auto propertyMapper = QSharedPointer<ReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> >::create();
@@ -38,3 +47,17 @@ QSharedPointer<ReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> >
38 return propertyMapper; 47 return propertyMapper;
39} 48}
40 49
50template <>
51QSharedPointer<WritePropertyMapper<Akonadi2::ApplicationDomain::Buffer::EventBuilder> > initializeWritePropertyMapper<Akonadi2::ApplicationDomain::Buffer::EventBuilder>()
52{
53 auto propertyMapper = QSharedPointer<WritePropertyMapper<Akonadi2::ApplicationDomain::Buffer::EventBuilder> >::create();
54 propertyMapper->addMapping("summary", [](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(Akonadi2::ApplicationDomain::Buffer::EventBuilder &)> {
55 auto offset = extractProperty<QString>(value, fbb);
56 return [offset](Akonadi2::ApplicationDomain::Buffer::EventBuilder &builder) { builder.add_summary(offset); };
57 });
58 propertyMapper->addMapping("uid", [](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(Akonadi2::ApplicationDomain::Buffer::EventBuilder &)> {
59 auto offset = extractProperty<QString>(value, fbb);
60 return [offset](Akonadi2::ApplicationDomain::Buffer::EventBuilder &builder) { builder.add_uid(offset); };
61 });
62 return propertyMapper;
63}