Slightly related question to this one and this one.
Basically, I would like to serialize objects as they come, much like a log file, except that I want to unserialize them later. This means that I don't have all the objects initially.
From previous answers, it looks like if one keeps the same archive open, one can keep on adding more and more objects to the archive.
But how would I extract them? Do I need to look ahead and see whether eof is reached before each extraction? Should I place a linebreak into the saving routine so that I can later read the input line by line (this would probably only work with binary archives (and maybe text), as xml uses linebreaks, and maybe not even there if binary might use a linebreak occasionally)? Maybe the >> operation throws an exception if the file end is reached and I can wrap it in an infinite loop with a try catch around it?
And how would I go about it if I wanted to do so for different kinds of objects? Maybe have an enum for all objects and serialize the enum just before, and on unserializing have a switch based on the enum?
Thanks