Skip to content

Latest commit

 

History

History
41 lines (31 loc) · 1.23 KB

README.md

File metadata and controls

41 lines (31 loc) · 1.23 KB

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.