serialization, many archives, cheap descrimination
Hello List, I have several classes, each put into it's own binary archive. How can I cheaply and efficiently determine the class type of a binary archive so that I know how to restore it? Thanks, Vic
Hmmm - consider using variant which lists your classes and serializing the variant. Serialization of variant is already in the package. Robert Ramey Victor Whiskey Yankee wrote:
Hello List,
I have several classes, each put into it's own binary archive.
How can I cheaply and efficiently determine the class type of a binary archive so that I know how to restore it?
Thanks, Vic
Whiskey Yankee wrote:
Robert Ramey wrote:
Hmmm - consider using variant which lists your classes and serializing the variant.
I assume you mean the boost variant. It looks promising but I wonder how that affects the size of the archive, given that different objects in the "union" will have drastically different sizes themselves?
If I'm reading the header file correctly, a variant is serialized as an integer followed by the serialization of whatever type it holds. The serialization is not affected in any way by the other types the variant might hold; only the one it is holding at the moment. This seems like a pretty efficient way to serialize an arbitrary object.
participants (3)
-
Andrew Holden
-
Robert Ramey
-
Victor Whiskey Yankee