flatten 20260225
This commit is contained in:
36
tjp/core/variant/VariantSerialization.hpp
Normal file
36
tjp/core/variant/VariantSerialization.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "VariantIO.hpp"
|
||||
|
||||
namespace tjp {
|
||||
namespace core {
|
||||
namespace variant {
|
||||
|
||||
struct VariantSerialization
|
||||
{
|
||||
typedef std::vector<char> Block;
|
||||
|
||||
Type_ type;
|
||||
Block block;
|
||||
|
||||
VariantSerialization() {}
|
||||
|
||||
template<typename IO>
|
||||
VariantSerialization(const Variant &v, IO &io)
|
||||
{
|
||||
auto &v_ = const_cast<Variant &>(v);
|
||||
|
||||
auto io_ = io.partial();
|
||||
|
||||
VariantIO vio{ v_.type, v_ };
|
||||
io_.object("type", v.type, "value", io_.custom(vio));
|
||||
|
||||
type = v.type;
|
||||
block = io_.partial_serialization();
|
||||
} ;
|
||||
} ;
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user