summaryrefslogtreecommitdiffstats
path: root/common/propertymapper.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/propertymapper.h')
-rw-r--r--common/propertymapper.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/common/propertymapper.h b/common/propertymapper.h
index cf8ce7b..edbc7f1 100644
--- a/common/propertymapper.h
+++ b/common/propertymapper.h
@@ -40,7 +40,8 @@ template <typename T>
40QVariant SINK_EXPORT propertyToVariant(uint8_t); 40QVariant SINK_EXPORT propertyToVariant(uint8_t);
41template <typename T> 41template <typename T>
42QVariant SINK_EXPORT propertyToVariant(const flatbuffers::Vector<uint8_t> *); 42QVariant SINK_EXPORT propertyToVariant(const flatbuffers::Vector<uint8_t> *);
43 43template <typename T>
44QVariant SINK_EXPORT propertyToVariant(const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *);
44 45
45/** 46/**
46 * The property mapper is a non-typesafe virtual dispatch. 47 * The property mapper is a non-typesafe virtual dispatch.
@@ -100,6 +101,12 @@ public:
100 addMapping(name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<T>((buffer->*f)()); }); 101 addMapping(name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<T>((buffer->*f)()); });
101 } 102 }
102 103
104 template <typename T, typename Buffer>
105 void addMapping(const QByteArray &name, const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *(Buffer::*f)() const)
106 {
107 addMapping(name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<T>((buffer->*f)()); });
108 }
109
103private: 110private:
104 QHash<QByteArray, std::function<QVariant(BufferType const *)>> mReadAccessors; 111 QHash<QByteArray, std::function<QVariant(BufferType const *)>> mReadAccessors;
105}; 112};
@@ -160,6 +167,15 @@ public:
160 }); 167 });
161 } 168 }
162 169
170 template <typename T>
171 void addMapping(const QByteArray &name, void (BufferBuilder::*f)(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>>))
172 {
173 addMapping(name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> {
174 auto offset = variantToProperty<T>(value, fbb);
175 return [offset, f](BufferBuilder &builder) { (builder.*f)(offset); };
176 });
177 }
178
163private: 179private:
164 QHash<QByteArray, std::function<std::function<void(BufferBuilder &)>(const QVariant &, flatbuffers::FlatBufferBuilder &)>> mWriteAccessors; 180 QHash<QByteArray, std::function<std::function<void(BufferBuilder &)>(const QVariant &, flatbuffers::FlatBufferBuilder &)>> mWriteAccessors;
165}; 181};