vendredi 19 août 2022

Runtime Reflection Library for c++ that allow serialization and deserialization of custom types

I'm looking for a library that allows to serialize and deserialize custom types in a few lines of code.

I've already tested this library RTTR, but unluckily it does not fit my purpose (also is poorly documented).

What I wish to achieve in pseudo-code is something like:

void serializeInstance(instance)
{
    for (property in instance)
    {
        serializeProperty("propertyName", property);
    }
}

void deserializeInstance()
{
    // Getting the type of the component from a string stored in a file
    type = getType(component["Type"]); 

    decltype(type) component;
    
    properties = getProperties(component["Properties"]);

    for (propertyName in properties)
    {
        // need to cast this to the right type
        component.property = getPropertyValue(propertyName["Value"]);
    }
}

To make it simple I'm trying to do something similar to what Unity does with the serialization of components.





Aucun commentaire:

Enregistrer un commentaire