Commit 0fc7c3a5 authored by Dominik Charousset's avatar Dominik Charousset

Make binary_serializer an alias type

parent 38fa6481
...@@ -32,7 +32,6 @@ set(LIBCAF_CORE_SRCS ...@@ -32,7 +32,6 @@ set(LIBCAF_CORE_SRCS
src/behavior_impl.cpp src/behavior_impl.cpp
src/behavior_stack.cpp src/behavior_stack.cpp
src/binary_deserializer.cpp src/binary_deserializer.cpp
src/binary_serializer.cpp
src/blocking_actor.cpp src/blocking_actor.cpp
src/blocking_behavior.cpp src/blocking_behavior.cpp
src/chars.cpp src/chars.cpp
......
...@@ -18,97 +18,12 @@ ...@@ -18,97 +18,12 @@
#pragma once #pragma once
#include <cstddef>
#include <cstdint>
#include <vector> #include <vector>
#include "caf/serializer.hpp" #include "caf/serializer_impl.hpp"
namespace caf { namespace caf {
/// Implements the serializer interface with a binary serialization protocol. using binary_serializer = serializer_impl<std::vector<char>>;
class binary_serializer final : public serializer {
public:
// -- member types -----------------------------------------------------------
using super = serializer;
using buffer = std::vector<char>;
// -- constructors, destructors, and assignment operators --------------------
binary_serializer(actor_system& sys, buffer& buf);
binary_serializer(execution_unit* ctx, buffer& buf);
// -- position management ----------------------------------------------------
/// Sets the write position to given offset.
/// @pre `offset <= buf.size()`
void seek(size_t offset);
/// Jumps `num_bytes` forward. Resizes the buffer (filling it with zeros)
/// when skipping past the end.
void skip(size_t num_bytes);
// -- overridden member functions --------------------------------------------
error begin_object(uint16_t& typenr, std::string& name) override;
error end_object() override;
error begin_sequence(size_t& list_size) override;
error end_sequence() override;
error apply_raw(size_t num_bytes, void* data) override;
// -- properties -------------------------------------------------------------
buffer& buf() {
return buf_;
}
const buffer& buf() const {
return buf_;
}
size_t write_pos() const noexcept {
return write_pos_;
}
protected:
error apply_impl(int8_t&) override;
error apply_impl(uint8_t&) override;
error apply_impl(int16_t&) override;
error apply_impl(uint16_t&) override;
error apply_impl(int32_t&) override;
error apply_impl(uint32_t&) override;
error apply_impl(int64_t&) override;
error apply_impl(uint64_t&) override;
error apply_impl(float&) override;
error apply_impl(double&) override;
error apply_impl(long double&) override;
error apply_impl(std::string&) override;
error apply_impl(std::u16string&) override;
error apply_impl(std::u32string&) override;
private:
buffer& buf_;
size_t write_pos_;
};
} // namespace caf } // namespace caf
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <tuple> #include <tuple>
#include <vector>
#include "caf/detail/is_one_of.hpp" #include "caf/detail/is_one_of.hpp"
#include "caf/detail/is_primitive_config_value.hpp" #include "caf/detail/is_primitive_config_value.hpp"
...@@ -39,6 +40,7 @@ template <class> class intrusive_cow_ptr; ...@@ -39,6 +40,7 @@ template <class> class intrusive_cow_ptr;
template <class> class intrusive_ptr; template <class> class intrusive_ptr;
template <class> class optional; template <class> class optional;
template <class> class param; template <class> class param;
template <class> class serializer_impl;
template <class> class stream; template <class> class stream;
template <class> class stream_sink; template <class> class stream_sink;
template <class> class stream_source; template <class> class stream_source;
...@@ -89,7 +91,6 @@ class actor_system; ...@@ -89,7 +91,6 @@ class actor_system;
class actor_system_config; class actor_system_config;
class behavior; class behavior;
class binary_deserializer; class binary_deserializer;
class binary_serializer;
class blocking_actor; class blocking_actor;
class config_option; class config_option;
class config_option_adder; class config_option_adder;
...@@ -173,11 +174,11 @@ enum class stream_priority; ...@@ -173,11 +174,11 @@ enum class stream_priority;
// -- aliases ------------------------------------------------------------------ // -- aliases ------------------------------------------------------------------
using actor_id = uint64_t; using actor_id = uint64_t;
using binary_serializer = serializer_impl<std::vector<char>>;
using ip_address = ipv6_address; using ip_address = ipv6_address;
using ip_subnet = ipv6_subnet; using ip_subnet = ipv6_subnet;
using stream_slot = uint16_t;
using settings = dictionary<config_value>; using settings = dictionary<config_value>;
using stream_slot = uint16_t;
// -- functions ---------------------------------------------------------------- // -- functions ----------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment