7#ifndef SOLANET_SERIALIZER_SERIALIZER_H_
8#define SOLANET_SERIALIZER_SERIALIZER_H_
10#ifndef CPPCHECK_IGNORE
11#include <cereal/archives/binary.hpp>
12#include <cereal/cereal.hpp>
13#include <cereal/types/array.hpp>
14#include <cereal/types/optional.hpp>
15#include <cereal/types/set.hpp>
16#include <cereal/types/string.hpp>
17#include <cereal/types/tuple.hpp>
18#include <cereal/types/unordered_map.hpp>
19#include <cereal/types/variant.hpp>
20#include <cereal/types/vector.hpp>
25namespace solanet::serializer {
29template <
typename T,
typename SerializerType = BinarySerializer>
30std::string serialize(
const T &msg) {
31 static_assert(std::is_class_v<SerializerType>);
35 if constexpr (std::is_same_v<SerializerType, BinarySerializer>) {
36 cereal::BinaryOutputArchive archive(ss);
39 static_assert(std::is_void_v<SerializerType>);
45template <
typename T,
typename SerializerType = BinarySerializer>
46T deserialize(
const std::string &msg) {
47 static_assert(std::is_class_v<SerializerType>);
50 std::istringstream iss(msg);
52 if constexpr (std::is_same_v<SerializerType, BinarySerializer>) {
53 cereal::BinaryInputArchive a(iss);
56 static_assert(std::is_void_v<SerializerType>);
Definition serializer.h:27