nicktrandafil / yenxo

Enables automatic serialization/deserialization for user defined types. Uses `boost::hana` to inject reflection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yenxo

Build Status codecov Documentation

Some add-in's which enable the traits listed below for user defined types:

  • serialization/deserialization;
  • comparison;
  • pushing to std::ostream.

Uses boost::hana in order to obtain reflection in C++. Uses rapidjson to serialize to and deserialize form JSON.

Examples

Typical use case of trait::Var:

struct Person : trait::Var<Person> {
    std::string name;
    int age;
    float height;
};

BOOST_HANA_ADAPT_STRUCT(Person, name, age, height);

auto const json = R"(
    {
        "name": "An uncommon name",
        "age": 20,
        "height": "170.5"
    }
)";

// Construct from JSON
Person person(Variant::from(rapidjson::Document().Parse(json)));

More snippets can be found in examples and test directories. The documentation can be found here.

About

Enables automatic serialization/deserialization for user defined types. Uses `boost::hana` to inject reflection

License:MIT License


Languages

Language:C++ 99.2%Language:CMake 0.7%Language:Shell 0.1%