C++ Actor Framework 1.0.0
Loading...
Searching...
No Matches
caf::binary_serializer Class Reference

Serializes C++ objects into a sequence of bytes. More...

#include <binary_serializer.hpp>

Inherits caf::save_inspector_base< Subtype >.

Public Types

using super = save_inspector_base<binary_serializer>
 
using container_type = byte_buffer
 
using value_type = std::byte
 

Public Member Functions

 binary_serializer (byte_buffer &buf) noexcept
 
 binary_serializer (actor_system &sys, byte_buffer &buf) noexcept
 
 binary_serializer (std::nullptr_t, byte_buffer &buf) noexcept
 
 binary_serializer (const binary_serializer &)=delete
 
binary_serializeroperator= (const binary_serializer &)=delete
 
actor_systemcontext () const noexcept
 Returns the current execution unit.
 
byte_bufferbuf () noexcept
 
const byte_bufferbuf () const noexcept
 
size_t write_pos () const noexcept
 
void seek (size_t offset) noexcept
 Sets the write position to offset.
 
void skip (size_t num_bytes)
 Jumps num_bytes forward.
 
constexpr bool begin_object (type_id_t, std::string_view) noexcept
 
constexpr bool end_object ()
 
constexpr bool begin_field (std::string_view) noexcept
 
bool begin_field (std::string_view, bool is_present)
 
bool begin_field (std::string_view, span< const type_id_t > types, size_t index)
 
bool begin_field (std::string_view, bool is_present, span< const type_id_t > types, size_t index)
 
constexpr bool end_field ()
 
constexpr bool begin_tuple (size_t)
 
constexpr bool end_tuple ()
 
constexpr bool begin_key_value_pair ()
 
constexpr bool end_key_value_pair ()
 
bool begin_sequence (size_t list_size)
 
constexpr bool end_sequence ()
 
bool begin_associative_array (size_t size)
 
bool end_associative_array ()
 
bool value (std::byte x)
 
bool value (bool x)
 
bool value (int8_t x)
 
bool value (uint8_t x)
 
bool value (int16_t x)
 
bool value (uint16_t x)
 
bool value (int32_t x)
 
bool value (uint32_t x)
 
bool value (int64_t x)
 
bool value (uint64_t x)
 
template<class T >
std::enable_if_t< std::is_integral_v< T >, bool > value (T x)
 
bool value (float x)
 
bool value (double x)
 
bool value (long double x)
 
bool value (std::string_view x)
 
bool value (const std::u16string &x)
 
bool value (const std::u32string &x)
 
bool value (span< const std::byte > x)
 
bool value (const std::vector< bool > &x)
 

Static Public Member Functions

static constexpr bool has_human_readable_format () noexcept
 

Detailed Description

Serializes C++ objects into a sequence of bytes.

Note
The binary data format may change between CAF versions and does not perform any type checking at run-time. Thus the output of this serializer is unsuitable for persistence layers.

Member Function Documentation

◆ seek()

void caf::binary_serializer::seek ( size_t offset)
noexcept

Sets the write position to offset.

Precondition
offset <= buf.size()

◆ skip()

void caf::binary_serializer::skip ( size_t num_bytes)

Jumps num_bytes forward.

Resizes the buffer (filling it with zeros) when skipping past the end.


The documentation for this class was generated from the following files: