6#include <unordered_map>
7#include <unordered_set>
17 explicit Serializer(std::shared_ptr<Writer> writer) : writer(std::move(writer)) {}
22 requires std::is_trivially_destructible<T>::value || std::is_same<std::string, T>::value
24 writer->write((uint8_t*)&value,
sizeof(T));
35 void write(
const uint8_t* value, uint64_t len) { writer->write(value, len); }
40 if (value !=
nullptr) {
41 value->serialize(*
this);
45 template<
typename T1,
typename T2>
47 uint64_t mapSize = values.size();
49 for (
auto& value : values) {
51 value.second->serialize(*
this);
57 uint64_t vectorSize = values.size();
59 for (
auto& value : values) {
60 if constexpr (
requires(
Serializer& ser) { value.serialize(ser); }) {
61 value.serialize(*
this);
68 template<
typename T, u
int64_t ARRAY_SIZE>
70 for (
auto& value : values) {
71 if constexpr (
requires(
Serializer& ser) { value.serialize(ser); }) {
72 value.serialize(*
this);
81 uint64_t vectorSize = values.size();
83 for (
auto& value : values) {
84 value->serialize(*
this);
90 uint64_t setSize = values.size();
92 for (
const auto& value : values) {
98 std::shared_ptr<Writer> writer;
Definition serializer.h:15
void writeDebuggingInfo(const std::string &value)
void serializeValue(const T &value)
Definition serializer.h:23
void serializeVectorOfPtrs(const std::vector< std::unique_ptr< T > > &values)
Definition serializer.h:80
void write(const T &value)
Definition serializer.h:29
void write(const uint8_t *value, uint64_t len)
Definition serializer.h:35
void serializeUnorderedSet(const std::unordered_set< T > &values)
Definition serializer.h:89
void serializeUnorderedMap(const std::unordered_map< T1, std::unique_ptr< T2 > > &values)
Definition serializer.h:46
void serializeArray(const std::array< T, ARRAY_SIZE > &values)
Definition serializer.h:69
void serializeOptionalValue(const std::unique_ptr< T > &value)
Definition serializer.h:38
Writer & getWriter() const
Definition serializer.h:19
void serializeVector(const std::vector< T > &values)
Definition serializer.h:56
Serializer(std::shared_ptr< Writer > writer)
Definition serializer.h:17
Definition alter_type.h:5