Serialization

All the metadata types and some other Atoms objects can be serialized/deserialized to and from the disk.

To serialize an object you need to create an archive object and use the serialize functions or the << operator.

AtomsCore::DoubleMetadata doubleMeta(5.6);

AtomsCore::Archive archive(doubleMeta.memSize());
archive << doubleMeta;
// or
doubleMeta.serialize(archive);

AtomsCore::IntMetadata intMeta(8);
AtomsCore::MapMetadata mapMeta;
mapMeta.addEntry("key1", &doubleMeta);
mapMeta.addEntry("key2", &intMeta);
AtomsCore::Archive archiveMap(mapMeta.memSize());
mapMeta.serialise(archiveMap);
archiveMap.writeToFile("myArchive.atoms")


To deserialize use the deserialise functions or the >> operator

AtomsCore::MapMetadata mapMeta;
AtomsCore::Archive archiveMap;
if (archiveMap.readFromFile("myArchive.atoms"))
{
	mapMeta.deserialise(archiveMap);
}

Copyright © 2017, Toolchefs LTD.