41 lines
706 B
C++
41 lines
706 B
C++
// License: Modified MIT (NON-AI)
|
|
// See the LICENSE file in the root directory for license information.
|
|
// Copyright 2026 Timothy Prepscius
|
|
|
|
#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
|
|
|