I looked at documentations of both Boost Serialization and Cereal library but I didn't find anything specific. I'm wondering if it's possible to have an integrity check in the serialized data. I'm not talking about the security aspect but if for any reason the file saved is corrupted, the data loaded can be totally wrong. Is there anything supported in these libraries about this aspect? I thought to implement something similar myself but there's a problem in the load phase for both libraries:
template<class Archive>
void load(Archive& ar) {
//checksum here??
ar >> mydata;
}
In order to calculate the checksum I need to read all data. However for both libraries I can't extract anything from archive, I can just fill the class attributes hoping everything is loaded without errors and then I can calculate the checksum. I'd like to calculate the checksum before to load class attributes. Is it possible?