Serialisation: Add std::span wrappers for Recv_binary, Send_binary

This commit is contained in:
Jonathan G Rennison
2024-02-06 18:35:44 +00:00
parent 2208d70e33
commit bb627e944c

View File

@@ -78,9 +78,9 @@ struct BufferSerialisationHelper {
BufferSend_binary(self->GetSerialisationBuffer(), self->GetSerialisationLimit(), data, size); BufferSend_binary(self->GetSerialisationBuffer(), self->GetSerialisationLimit(), data, size);
} }
void Send_binary(const byte *data, const byte *end) void Send_binary(std::span<const byte> data)
{ {
this->Send_binary(data, end - data); this->Send_binary(data.data(), data.size());
} }
void Send_buffer(const byte *data, const size_t size) void Send_buffer(const byte *data, const size_t size)
@@ -263,6 +263,15 @@ public:
pos += (decltype(pos)) size; pos += (decltype(pos)) size;
} }
/**
* Reads binary data.
* @param buffer The buffer to put the data into.
*/
void Recv_binary(std::span<byte> buffer)
{
this->Recv_binary(buffer.data(), buffer.size());
}
/** /**
* Returns view of binary data. * Returns view of binary data.
* @param size The size of the data. * @param size The size of the data.