actor-framework
Public Types | Public Member Functions | Static Public Member Functions | List of all members
caf::binary_serializer Class Reference

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

#include <binary_serializer.hpp>

Inheritance diagram for caf::binary_serializer:
Inheritance graph
[legend]
Collaboration diagram for caf::binary_serializer:
Collaboration graph
[legend]

Public Types

using super = save_inspector_base< binary_serializer >
 
using container_type = byte_buffer
 
using value_type = std::byte
 
- Public Types inherited from caf::save_inspector_base< binary_serializer >
using super = save_inspector
 

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. More...
 
void skip (size_t num_bytes)
 Jumps num_bytes forward. More...
 
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)
 
- Public Member Functions inherited from caf::save_inspector_base< binary_serializer >
constexpr auto object (T &) noexcept
 
constexpr auto virtual_object (std::string_view type_name) noexcept
 
bool begin_object_t ()
 
bool list (const T &xs)
 
bool map (const T &xs)
 
bool tuple (const T &xs, std::index_sequence< Is... >)
 
bool tuple (const T &xs)
 
bool tuple (T(&xs)[N])
 
bool apply (const T &x)
 
bool apply (Get &&get, Set &&)
 
- Public Member Functions inherited from caf::save_inspector
void set_error (error stop_reason)
 
template<class... Ts>
void emplace_error (Ts &&... xs)
 
const errorget_error () const noexcept
 
error && move_error () noexcept
 
template<class... Ts>
void field_invariant_check_failed (std::string msg)
 
template<class... Ts>
void field_value_synchronization_failed (std::string msg)
 
template<class... Ts>
void invalid_field_type (std::string msg)
 

Static Public Member Functions

static constexpr bool has_human_readable_format () noexcept
 
- Static Public Member Functions inherited from caf::save_inspector
template<class T >
static auto field (std::string_view name, T &x)
 
template<class Get , class Set >
static auto field (std::string_view name, Get get, Set &&)
 
template<class IsPresent , class Get , class... Ts>
static auto field (std::string_view name, IsPresent is_present, Get get, Ts &&...)
 

Additional Inherited Members

- Static Public Attributes inherited from caf::save_inspector
static constexpr bool is_loading = false
 Enables dispatching on the inspector type.
 
- Protected Attributes inherited from caf::save_inspector
error err_
 

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)
inlinenoexcept

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: