diff options
Diffstat (limited to 'common/propertymapper.h')
-rw-r--r-- | common/propertymapper.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/common/propertymapper.h b/common/propertymapper.h index 70491a1..9ea0b73 100644 --- a/common/propertymapper.h +++ b/common/propertymapper.h | |||
@@ -29,6 +29,7 @@ namespace Sink { | |||
29 | namespace ApplicationDomain { | 29 | namespace ApplicationDomain { |
30 | namespace Buffer { | 30 | namespace Buffer { |
31 | struct MailContact; | 31 | struct MailContact; |
32 | struct ContactEmail; | ||
32 | } | 33 | } |
33 | } | 34 | } |
34 | } | 35 | } |
@@ -54,6 +55,8 @@ template <typename T> | |||
54 | QVariant SINK_EXPORT propertyToVariant(const Sink::ApplicationDomain::Buffer::MailContact *); | 55 | QVariant SINK_EXPORT propertyToVariant(const Sink::ApplicationDomain::Buffer::MailContact *); |
55 | template <typename T> | 56 | template <typename T> |
56 | QVariant SINK_EXPORT propertyToVariant(const flatbuffers::Vector<flatbuffers::Offset<Sink::ApplicationDomain::Buffer::MailContact>> *); | 57 | QVariant SINK_EXPORT propertyToVariant(const flatbuffers::Vector<flatbuffers::Offset<Sink::ApplicationDomain::Buffer::MailContact>> *); |
58 | template <typename T> | ||
59 | QVariant SINK_EXPORT propertyToVariant(const flatbuffers::Vector<flatbuffers::Offset<Sink::ApplicationDomain::Buffer::ContactEmail>> *); | ||
57 | 60 | ||
58 | /** | 61 | /** |
59 | * The property mapper is a non-typesafe virtual dispatch. | 62 | * The property mapper is a non-typesafe virtual dispatch. |
@@ -131,6 +134,12 @@ public: | |||
131 | addMapping(T::name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<typename T::Type>((buffer->*f)()); }); | 134 | addMapping(T::name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<typename T::Type>((buffer->*f)()); }); |
132 | } | 135 | } |
133 | 136 | ||
137 | template <typename T, typename Buffer> | ||
138 | void addMapping(const flatbuffers::Vector<flatbuffers::Offset<Sink::ApplicationDomain::Buffer::ContactEmail>> *(Buffer::*f)() const) | ||
139 | { | ||
140 | addMapping(T::name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<typename T::Type>((buffer->*f)()); }); | ||
141 | } | ||
142 | |||
134 | private: | 143 | private: |
135 | QHash<QByteArray, std::function<QVariant(BufferType const *)>> mReadAccessors; | 144 | QHash<QByteArray, std::function<QVariant(BufferType const *)>> mReadAccessors; |
136 | }; | 145 | }; |
@@ -218,6 +227,15 @@ public: | |||
218 | }); | 227 | }); |
219 | } | 228 | } |
220 | 229 | ||
230 | template <typename T> | ||
231 | void addMapping(void (BufferBuilder::*f)(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Sink::ApplicationDomain::Buffer::ContactEmail>>>)) | ||
232 | { | ||
233 | addMapping(T::name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> { | ||
234 | auto offset = variantToProperty<typename T::Type>(value, fbb); | ||
235 | return [offset, f](BufferBuilder &builder) { (builder.*f)(offset); }; | ||
236 | }); | ||
237 | } | ||
238 | |||
221 | private: | 239 | private: |
222 | QHash<QByteArray, std::function<std::function<void(BufferBuilder &)>(const QVariant &, flatbuffers::FlatBufferBuilder &)>> mWriteAccessors; | 240 | QHash<QByteArray, std::function<std::function<void(BufferBuilder &)>(const QVariant &, flatbuffers::FlatBufferBuilder &)>> mWriteAccessors; |
223 | }; | 241 | }; |