diff options
Diffstat (limited to 'common/propertymapper.h')
-rw-r--r-- | common/propertymapper.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/common/propertymapper.h b/common/propertymapper.h index 87c7485..98ad397 100644 --- a/common/propertymapper.h +++ b/common/propertymapper.h | |||
@@ -98,6 +98,17 @@ public: | |||
98 | void addMapping(const QByteArray &property, const std::function<std::function<void(BufferBuilder &)>(const QVariant &, flatbuffers::FlatBufferBuilder &)> &mapping) { | 98 | void addMapping(const QByteArray &property, const std::function<std::function<void(BufferBuilder &)>(const QVariant &, flatbuffers::FlatBufferBuilder &)> &mapping) { |
99 | mWriteAccessors.insert(property, mapping); | 99 | mWriteAccessors.insert(property, mapping); |
100 | } | 100 | } |
101 | |||
102 | template <typename T> | ||
103 | void addMapping(const QByteArray &name, void (BufferBuilder::*f)(flatbuffers::Offset<flatbuffers::String>)) | ||
104 | { | ||
105 | addMapping(name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> { | ||
106 | auto offset = variantToProperty<T>(value, fbb); | ||
107 | return [offset, f](BufferBuilder &builder) { | ||
108 | (builder.*f)(offset); | ||
109 | }; | ||
110 | }); | ||
111 | } | ||
101 | private: | 112 | private: |
102 | QHash<QByteArray, std::function<std::function<void(BufferBuilder &)>(const QVariant &, flatbuffers::FlatBufferBuilder &)> > mWriteAccessors; | 113 | QHash<QByteArray, std::function<std::function<void(BufferBuilder &)>(const QVariant &, flatbuffers::FlatBufferBuilder &)> > mWriteAccessors; |
103 | }; | 114 | }; |