Scarlet-Engine-Team-GameDev-McGill/Scarlet-Engine

Serialization and deserialization

Closed this issue · 0 comments

Describe the problem or limitation you are having:
I would like to be able to store the persistent state of some data in the engine to disk.

Describe the feature and how it will overcome the problem/limitation:
A serialization interface would allow developers to serialize the persistent state and then write it to some binary file on the disk.

How could your solution be implemented:
An Archive object could be implemented to overload the streaming operators to write data to an internal buffer. Once the user is finished, they can request the buffer be output to a binary file on the disk.

A potential API:

struct Position
{
    float x;
    float y;
    float z;

    void Serialize(Archive& Ar)
    {
        Ar << x
             << y
             << z;
    }
}

A similar approach can be taken for deserialization by overloading the >> operator.