Update read and write streaming api to use the newest format

This commit is contained in:
Wojtek Figat
2024-12-29 23:00:40 +01:00
parent fee0ab74ff
commit 668f3fa68d
29 changed files with 444 additions and 378 deletions

View File

@@ -178,6 +178,23 @@ public:
Write(v.Get());
}
template<typename T>
void Write(const Span<T>& data)
{
const int32 size = data.Length();
WriteInt32(size);
if (size > 0)
{
if (TIsPODType<T>::Value && !TIsPointer<T>::Value)
WriteBytes(data.Get(), size * sizeof(T));
else
{
for (int32 i = 0; i < size; i++)
Write(data[i]);
}
}
}
template<typename T, typename AllocationType = HeapAllocation>
void Write(const Array<T, AllocationType>& data)
{
@@ -216,42 +233,49 @@ public:
void WriteJson(ISerializable* obj, const void* otherObj = nullptr);
void WriteJson(const StringAnsiView& json);
// Serialization of math types with float or double depending on the context (must match deserialization)
// Set useDouble=true to explicitly use 64-bit precision for serialized data
void Write(const BoundingBox& box, bool useDouble = false);
void Write(const BoundingSphere& sphere, bool useDouble = false);
void Write(const Transform& transform, bool useDouble = false);
void Write(const Ray& ray, bool useDouble = false);
public:
// Writes String to the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
// @param data Data to write
void WriteString(const StringView& data);
DEPRECATED("Use Write method") void WriteString(const StringView& data);
// Writes String to the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
// @param data Data to write
// @param lock Characters pass in the stream
void WriteString(const StringView& data, int16 lock);
DEPRECATED("Use Write method") void WriteString(const StringView& data, int16 lock);
// Writes Ansi String to the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
void WriteStringAnsi(const StringAnsiView& data);
DEPRECATED("Use Write method") void WriteStringAnsi(const StringAnsiView& data);
// Writes Ansi String to the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
// @param data Data to write
// @param lock Characters pass in the stream
void WriteStringAnsi(const StringAnsiView& data, int8 lock);
DEPRECATED("Use Write method") void WriteStringAnsi(const StringAnsiView& data, int8 lock);
// Writes CommonValue to the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
// @param data Data to write
void WriteCommonValue(const CommonValue& data);
DEPRECATED("Use Write method") void WriteCommonValue(const CommonValue& data);
// Writes VariantType to the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
// @param data Data to write
void WriteVariantType(const VariantType& data);
DEPRECATED("Use Write method") void WriteVariantType(const VariantType& data);
// Writes Variant to the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
// @param data Data to write
void WriteVariant(const Variant& data);
DEPRECATED("Use Write method") void WriteVariant(const Variant& data);
/// <summary>
/// Write data array
@@ -259,18 +283,21 @@ public:
/// </summary>
/// <param name="data">Array to write</param>
template<typename T, typename AllocationType = HeapAllocation>
FORCE_INLINE void WriteArray(const Array<T, AllocationType>& data)
DEPRECATED("Use Write method") FORCE_INLINE void WriteArray(const Array<T, AllocationType>& data)
{
Write(data);
}
public:
// Serialization of math types with float or double depending on the context (must match deserialization)
// Set useDouble=true to explicitly use 64-bit precision for serialized data
void WriteBoundingBox(const BoundingBox& box, bool useDouble = false);
void WriteBoundingSphere(const BoundingSphere& sphere, bool useDouble = false);
void WriteTransform(const Transform& transform, bool useDouble = false);
void WriteRay(const Ray& ray, bool useDouble = false);
// [Deprecated in v1.10]
DEPRECATED("Use Write method") void WriteBoundingBox(const BoundingBox& box, bool useDouble = false);
// [Deprecated in v1.10]
DEPRECATED("Use Write method") void WriteBoundingSphere(const BoundingSphere& sphere, bool useDouble = false);
// [Deprecated in v1.10]
DEPRECATED("Use Write method") void WriteTransform(const Transform& transform, bool useDouble = false);
// [Deprecated in v1.10]
DEPRECATED("Use Write method") void WriteRay(const Ray& ray, bool useDouble = false);
public:
// [Stream]