Add a wrapper for serializing primitives

This commit is contained in:
Robbert van der Helm
2020-12-14 17:53:38 +01:00
parent d9585fac78
commit 6979dafa06
+22
View File
@@ -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 <typename T>
class PrimitiveWrapper {
public:
PrimitiveWrapper() {}
PrimitiveWrapper(T value) : value(value) {}
operator T() { return value; }
template <typename S>
void serialize(S& s) {
s.template value<sizeof(T)>(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