2#include "gaia/config/config.h"
4#include "gaia/mem/mem_alloc.h"
5#include "gaia/ser/ser_buffer_binary.h"
6#include "gaia/ser/ser_rt.h"
14 void align(uint32_t size, ser::serialization_type_id
id) {
15 const auto pos = m_buffer.
tell();
16 const auto posAligned = mem::align(pos, ser::serialization_type_size(
id, size));
17 const auto offset = posAligned - pos;
18 m_buffer.
reserve(offset + size);
19 m_buffer.
skip(offset);
23 void save_raw(
const void* src, uint32_t size, ser::serialization_type_id
id)
override {
25 m_buffer.
save_raw((
const char*)src, size,
id);
28 void load_raw(
void* src, uint32_t size, ser::serialization_type_id
id)
override {
30 m_buffer.
load_raw((
char*)src, size,
id);
33 const char* data()
const override {
34 return (
const char*)m_buffer.
data();
37 void reset()
override {
41 uint32_t tell()
const override {
42 return m_buffer.
tell();
45 uint32_t bytes()
const override {
46 return m_buffer.
bytes();
49 void seek(uint32_t pos)
override {
Definition ser_binary.h:10
void seek(uint32_t pos)
Changes the current position in the buffer.
Definition ser_buffer_binary.h:69
GAIA_NODISCARD uint32_t tell() const
Returns the current position in the buffer.
Definition ser_buffer_binary.h:80
GAIA_NODISCARD uint32_t bytes() const
Returns the number of bytes written in the buffer.
Definition ser_buffer_binary.h:34
GAIA_NODISCARD const auto * data() const
Returns the pointer to the data in the buffer.
Definition ser_buffer_binary.h:44
void reserve(uint32_t size)
Makes sure there is enough capacity in our data container to hold another size bytes of data.
Definition ser_buffer_binary.h:50
void load_raw(void *pDst, uint32_t size, ser::serialization_type_id id)
Loads size bytes of data from the buffer and writes it to the address pDst.
Definition ser_buffer_binary.h:134
void skip(uint32_t size)
Advances size bytes from the current buffer position.
Definition ser_buffer_binary.h:75
void save_raw(const void *pSrc, uint32_t size, ser::serialization_type_id id)
Writes size bytes of data starting at the address pSrc to the buffer.
Definition ser_buffer_binary.h:103
Minimal binary serializer meant to runtime data. It does not offer any versioning,...
Definition ser_buffer_binary.h:153
Checks if endianess was detected correctly at compile-time.
Definition bitset.h:9