Skip to content
Snippets Groups Projects
Select Git revision
  • socrate-v33
  • boardcore-changes-needed
  • master default protected
3 results

socrate

  • Clone with SSH
  • Clone with HTTPS
  • Davide Mor's avatar
    Davide Mor authored
    17b4e8f1
    History
    Name Last commit Last update
    examples
    README.md
    reflect.hpp
    userde.hpp

    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 macros (NOT RECOMMENDED)
    struct Foo {
        int a;
        float b;
    
        constexpr static auto reflect() {
            return struct_def<Foo>("Foo",
                field_def(&Foo::a, "a"),
                field_def(&Foo::b, "b"));
        }
    };
    
    // With macros
    struct Bar {
        int a;
        float b;
    
        constexpr static auto reflect() {
            return STRUCT_DEF(Bar,
                FIELD_DEF(a),
                FIELD_DEF(b));
        }
    };

    μ-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.