Skip to content

Commit

Permalink
deserialize data based on type added
Browse files Browse the repository at this point in the history
  • Loading branch information
riasc committed Oct 6, 2024
1 parent b9df893 commit f440270
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/Key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,41 @@ namespace genogrove {
bool hasData = false;
os.write(reinterpret_cast<const char*>(&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<char*>(&hasData), sizeof(hasData));

if(hasData) {
size_t typeNameLength;
is.read(reinterpret_cast<char*>(&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
Expand Down

0 comments on commit f440270

Please sign in to comment.