multiple serialized objects to same file
Hi! I know that this question is asked before but I cant see any answer about it. Is posible with boost serialization to write different objects to the same file? if is possible, is possible to access to each object with an iterator or with position like binary files? thanks -- Óscar Pernas Plaza.
"Oscar Pernas"
Is posible with boost serialization to write different objects to the same file?
Yes. Just serialize them one after the other: ar << x; ar << y; // Not necessarily the same type as x All that matters is that you deserialize the same types in the same order.
is possible to access to each object with an iterator or with position like binary files?
I'm not sure what you mean. Can you give an example? There is no random access to archives. If the number of objects isn't known at compile time you could serialize the count first so that the deserialization code can find out how many to deserialize. You could also put your objects in an STL container, a vector for example, and serialize that.
participants (2)
-
Niklas Angare
-
Oscar Pernas