Socrate
Skyward API for reflecting structs and classes.
Goals:
- simple to use
- just the bare minimum
- single header
- not too obscure
- easy to automatically generate (maybe maybe...)
Example
#include "reflect.hpp"
using namespace Skyward;
// Without the usage of any macro
namespace no_macros {
struct Foo {
int a;
float b;
constexpr static auto reflect() {
return struct_def<Foo>("Foo")
.add_field(&Foo::a, "a")
.add_field(&Foo::b, "b");
}
};
struct Bar : Foo {
int c;
float d;
constexpr static auto reflect() {
return struct_def<Bar>("Bar")
.add_extends<Foo>()
.add_field(&Bar::c, "c")
.add_field(&Bar::d, "d");
}
};
}
// With custom helper macros
namespace macros {
struct Foo {
int a;
float b;
constexpr static auto reflect() {
return STRUCT_DEF(Foo,
FIELD_DEF(a)
FIELD_DEF(b));
}
};
struct Bar : Foo {
int c;
float d;
constexpr static auto reflect() {
return STRUCT_DEF(Bar,
EXTENDS_DEF(Foo)
FIELD_DEF(c)
FIELD_DEF(d));
}
};
}
μ-serde
If you know, you know...
Microscopic serialization framework based on Socrate.
Define USERDE_STREAM_DESERIALIZER
before including the header if you want to enable the cool stream deserializer, disabled by default because it includes some really big libraries.
Serialization format is basically identical to the one used in tscpp, with the advantage of custom, stable, type names and compressed padding bytes.