Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
ISerializable.hpp
Go to the documentation of this file.
1#ifndef IV_CORE_ISERIALIZABLE_HPP
2#define IV_CORE_ISERIALIZABLE_HPP
3
4#include <vector>
5
6namespace iv::core
7{
8
10{
11public:
12 virtual ~ISerializable() = default;
13
14 template<typename T>
15 requires std::is_base_of_v<ISerializable, T>
16 static std::vector<std::byte> serialize(const T &object)
17 {
18 return object.serialize();
19 }
20
21protected:
22 [[nodiscard]] virtual std::vector<std::byte> serialize() const = 0;
23 virtual bool deserialize(const std::vector<std::byte> &data) = 0;
24};
25
26}// namespace iv::core
27
28#endif//IV_CORE_ISERIALIZABLE_HPP
Definition ISerializable.hpp:10
virtual ~ISerializable()=default
static std::vector< std::byte > serialize(const T &object)
Definition ISerializable.hpp:16
virtual std::vector< std::byte > serialize() const =0
virtual bool deserialize(const std::vector< std::byte > &data)=0
Definition ipUtils.cpp:11