// E04-Serialization.cpp -- object serialization and deserialization example

#include <Platform.h>
using namespace Platform;
using namespace Platform::Containers;


// program entry point
//====================================================================================================
AppMain(args)
{
    // local scope
    {
        // create a container and put some values into it
        HashMap<String, Int> container;
        container.add("123", 1);
        container.add("abcd", 2);
        container.add("alpha", 3);
        container.add("beta", -5);
        container.add("gamma", 963);

        // serialize the container into a file
        Io::FileSerializer serializer(Path("test.bin"));
        serializer << container;
    }

    // local scope
    {
        // create a container to hold deserialized values
        HashMap<String, Int> container;

        // deserialize data from a file
        Io::FileDeserializer deserializer(Path("test.bin"));
        deserializer >> container;

        // dump deserialized container to StdOut
        Runtime::StdOut::println(container.toString());
    }

    return 0;
}


/* EOF */