57 lines
2.4 KiB
C++
57 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include <Nazara/Core/Serialization.hpp>
|
|
|
|
namespace Nz
|
|
{
|
|
|
|
struct NAZARA_CORE_API BinarySerializationContext final
|
|
: public SerializationContext
|
|
{
|
|
public:
|
|
EnumSerializationMode GetEnumSerializationMode() const override { return EnumSerializationMode::Binary; }
|
|
|
|
bool PushObject(std::string_view name) override;
|
|
bool PopObject() override;
|
|
bool PushArray(std::string_view name) override;
|
|
bool PopArray() override;
|
|
|
|
bool Write(std::string_view name, bool value) override;
|
|
bool Write(std::string_view name, Nz::Int8 value) override;
|
|
bool Write(std::string_view name, Nz::Int16 value) override;
|
|
bool Write(std::string_view name, Nz::Int32 value) override;
|
|
bool Write(std::string_view name, Nz::Int64 value) override;
|
|
bool Write(std::string_view name, Nz::UInt8 value) override;
|
|
bool Write(std::string_view name, Nz::UInt16 value) override;
|
|
bool Write(std::string_view name, Nz::UInt32 value) override;
|
|
bool Write(std::string_view name, Nz::UInt64 value) override;
|
|
bool Write(std::string_view name, float value) override;
|
|
bool Write(std::string_view name, double value) override;
|
|
bool Write(std::string_view name, const std::string& value) override;
|
|
|
|
bool Read(std::string_view name, bool* value) override;
|
|
bool Read(std::string_view name, Nz::Int8* value) override;
|
|
bool Read(std::string_view name, Nz::Int16* value) override;
|
|
bool Read(std::string_view name, Nz::Int32* value) override;
|
|
bool Read(std::string_view name, Nz::Int64* value) override;
|
|
bool Read(std::string_view name, Nz::UInt8* value) override;
|
|
bool Read(std::string_view name, Nz::UInt16* value) override;
|
|
bool Read(std::string_view name, Nz::UInt32* value) override;
|
|
bool Read(std::string_view name, Nz::UInt64* value) override;
|
|
bool Read(std::string_view name, float* value) override;
|
|
bool Read(std::string_view name, double* value) override;
|
|
bool Read(std::string_view name, std::string* value) override;
|
|
|
|
MovablePtr<Stream> stream;
|
|
Endianness endianness = Endianness::BigEndian; //< Default to Big Endian encoding
|
|
UInt8 readBitPos = 8; //< 8 means no bit is currently read
|
|
UInt8 readByte; //< Undefined value, will be initialized at the first bit read
|
|
UInt8 writeBitPos = 8; //< 8 means no bit is currently wrote
|
|
UInt8 writeByte; //< Undefined value, will be initialized at the first bit write
|
|
|
|
void FlushBits();
|
|
void ResetReadBitPosition();
|
|
void ResetWriteBitPosition();
|
|
};
|
|
}
|