Atoms Crowd  7.0.0
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);
mapMeta.addEntry("key1", &doubleMeta);
mapMeta.addEntry("key2", &intMeta);
AtomsCore::Archive archiveMap(mapMeta.memSize());
mapMeta.serialise(archiveMap);
archiveMap.writeToFile("myArchive.atoms")
Archive class.
Definition: Serialiser.h:29
MapMetadata class.
Definition: MapMetadata.h:24
void addEntry(const Key &key, AtomsPtr< Metadata > &data, bool cloneData=true)
Add an entry.
virtual size_t memSize() const
Memory size.
bool serialise(Archive &outStream) const
Serialise.

To deserialize use the deserialise functions or the >> operator

AtomsCore::Archive archiveMap;
if (archiveMap.readFromFile("myArchive.atoms"))
{
mapMeta.deserialise(archiveMap);
}
bool readFromFile(const std::string &fileName)
Reads a file and store inside the binary stream.
bool deserialise(Archive &inStream)
Deserialise.