From 6979dafa0694917cf01ad1ed054321c7f20e9ca3 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 14 Dec 2020 17:53:38 +0100 Subject: [PATCH] Add a wrapper for serializing primitives --- src/common/serialization/vst3/base.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/common/serialization/vst3/base.h b/src/common/serialization/vst3/base.h index d1155e35..1d7057e9 100644 --- a/src/common/serialization/vst3/base.h +++ b/src/common/serialization/vst3/base.h @@ -60,6 +60,28 @@ struct Ack { void serialize(S&) {} }; +/** + * A simple wrapper around primitive values for serialization purposes. Bitsery + * doesn't seem to like serializing plain primitives using `s.object()` even if + * you define a serialization function. + */ +template +class PrimitiveWrapper { + public: + PrimitiveWrapper() {} + PrimitiveWrapper(T value) : value(value) {} + + operator T() { return value; } + + template + void serialize(S& s) { + s.template value(value); + } + + private: + T value; +}; + /** * A wrapper around `Steinberg::tresult` that we can safely share between the * native plugin and the Wine process. Depending on the platform and on whether