From f440270968d86045c1b547e2f2398c1d2cbc5fa2 Mon Sep 17 00:00:00 2001 From: riasc Date: Sat, 5 Oct 2024 23:51:46 -0500 Subject: [PATCH] deserialize data based on type added --- src/Key.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Key.cpp b/src/Key.cpp index 910b3d6..c187e04 100644 --- a/src/Key.cpp +++ b/src/Key.cpp @@ -42,9 +42,41 @@ namespace genogrove { bool hasData = false; os.write(reinterpret_cast(&hasData), sizeof(hasData)); } + + // TODO: add serialization of singleLink and multiLink } Key Key::deserialize(std::istream& is) { + Interval interval = Interval::deserialize(is); + Key key(interval); + + // check of there is data to deserialize + bool hasData; + is.read(reinterpret_cast(&hasData), sizeof(hasData)); + + if(hasData) { + size_t typeNameLength; + is.read(reinterpret_cast(&typeNameLength), sizeof(typeNameLength)); + + std::string typeName(typeNameLength, '\0'); + is.read(&typeName[0], typeNameLength); + + // deserialize the data + key.data = key.data->deserialize(is); + } + + + + + + // read the type name + std::string typeName(typeNameLength, '\0'); + + + + + + Key key = Key::deserialize(is); // deserialize the data