WIP: Allow specifying version of binary serializable
This commit is contained in:
parent
cb98e348f1
commit
3f6f790849
|
@ -35,6 +35,10 @@ template <typename T> struct AdaptedBinarySerializable : public Traits::Bool<fal
|
||||||
|
|
||||||
template <typename Type> struct BinarySerializable;
|
template <typename Type> struct BinarySerializable;
|
||||||
|
|
||||||
|
template <typename Type> struct BinarySerializableMeta {
|
||||||
|
static constexpr std::uint64_t version = 0;
|
||||||
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief The BinaryReflector namespace contains BinaryReader and BinaryWriter for automatic binary (de)serialization.
|
* \brief The BinaryReflector namespace contains BinaryReader and BinaryWriter for automatic binary (de)serialization.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,6 +23,7 @@ template <typename Type> struct BinarySerializable {
|
||||||
static Type fromBinary(std::istream &inputStream);
|
static Type fromBinary(std::istream &inputStream);
|
||||||
|
|
||||||
static constexpr const char *qualifiedName = "ReflectiveRapidJSON::BinarySerializable";
|
static constexpr const char *qualifiedName = "ReflectiveRapidJSON::BinarySerializable";
|
||||||
|
static constexpr auto version = BinarySerializableMeta<Type>::version;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Type> inline void BinarySerializable<Type>::toBinary(std::ostream &outputStream) const
|
template <typename Type> inline void BinarySerializable<Type>::toBinary(std::ostream &outputStream) const
|
||||||
|
@ -53,6 +54,14 @@ template <typename Type> Type BinarySerializable<Type>::fromBinary(std::istream
|
||||||
template <> struct ReflectiveRapidJSON::AdaptedBinarySerializable<T> : Traits::Bool<true> { \
|
template <> struct ReflectiveRapidJSON::AdaptedBinarySerializable<T> : Traits::Bool<true> { \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def The REFLECTIVE_RAPIDJSON_DECLARE_BINARY_SERIALIZABLE_VERSION macro allows to declare the version of a BinarySerializable.
|
||||||
|
*/
|
||||||
|
#define REFLECTIVE_RAPIDJSON_DECLARE_BINARY_SERIALIZABLE_VERSION(T, v) \
|
||||||
|
template <> struct ReflectiveRapidJSON::BinarySerializableMeta<T> { \
|
||||||
|
static constexpr std::uint64_t version = v; \
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ReflectiveRapidJSON
|
} // namespace ReflectiveRapidJSON
|
||||||
|
|
||||||
#endif // REFLECTIVE_RAPIDJSON_BINARY_SERIALIZABLE_H
|
#endif // REFLECTIVE_RAPIDJSON_BINARY_SERIALIZABLE_H
|
||||||
|
|
Loading…
Reference in New Issue