summaryrefslogtreecommitdiffstats
path: root/common/propertymapper.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/propertymapper.h')
-rw-r--r--common/propertymapper.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/common/propertymapper.h b/common/propertymapper.h
index a63b7e7..70491a1 100644
--- a/common/propertymapper.h
+++ b/common/propertymapper.h
@@ -52,6 +52,8 @@ template <typename T>
52QVariant SINK_EXPORT propertyToVariant(const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *); 52QVariant SINK_EXPORT propertyToVariant(const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *);
53template <typename T> 53template <typename T>
54QVariant SINK_EXPORT propertyToVariant(const Sink::ApplicationDomain::Buffer::MailContact *); 54QVariant SINK_EXPORT propertyToVariant(const Sink::ApplicationDomain::Buffer::MailContact *);
55template <typename T>
56QVariant SINK_EXPORT propertyToVariant(const flatbuffers::Vector<flatbuffers::Offset<Sink::ApplicationDomain::Buffer::MailContact>> *);
55 57
56/** 58/**
57 * The property mapper is a non-typesafe virtual dispatch. 59 * The property mapper is a non-typesafe virtual dispatch.
@@ -123,6 +125,12 @@ public:
123 addMapping(T::name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<typename T::Type>((buffer->*f)()); }); 125 addMapping(T::name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<typename T::Type>((buffer->*f)()); });
124 } 126 }
125 127
128 template <typename T, typename Buffer>
129 void addMapping(const flatbuffers::Vector<flatbuffers::Offset<Sink::ApplicationDomain::Buffer::MailContact>> *(Buffer::*f)() const)
130 {
131 addMapping(T::name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<typename T::Type>((buffer->*f)()); });
132 }
133
126private: 134private:
127 QHash<QByteArray, std::function<QVariant(BufferType const *)>> mReadAccessors; 135 QHash<QByteArray, std::function<QVariant(BufferType const *)>> mReadAccessors;
128}; 136};
@@ -201,6 +209,15 @@ public:
201 }); 209 });
202 } 210 }
203 211
212 template <typename T>
213 void addMapping(void (BufferBuilder::*f)(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Sink::ApplicationDomain::Buffer::MailContact>>>))
214 {
215 addMapping(T::name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> {
216 auto offset = variantToProperty<typename T::Type>(value, fbb);
217 return [offset, f](BufferBuilder &builder) { (builder.*f)(offset); };
218 });
219 }
220
204private: 221private:
205 QHash<QByteArray, std::function<std::function<void(BufferBuilder &)>(const QVariant &, flatbuffers::FlatBufferBuilder &)>> mWriteAccessors; 222 QHash<QByteArray, std::function<std::function<void(BufferBuilder &)>(const QVariant &, flatbuffers::FlatBufferBuilder &)>> mWriteAccessors;
206}; 223};