Hi Stefan
Thank you very much for your answer!
> (sent data through network?),
...,
That's what I'm actually up to (omnet) in the end, but I thought of
just writing some sample code to ban such side effects. For the
problem described in my original post, I've only used the lines
stated there (no other archives).
I'll just have a closer look at your archive code, thanks a lot!
On 04.04.2013 15:39, Stefan Strasser
wrote:
Zitat von Alexander Striffeler
<a.striffeler@students.unibe.ch>:
However, both variants returned an invalid
signature exception even though I haven't changed anything on
the serialized data.
I cant think of a good reason why this would happen with your
code. invalid_signature is only thrown if the archive signature
isnt found at the beginning of the archive. so you should receive
this exception before deserializing any objects.
could be because the archive was created with the no_header flag,
or missing ios::binary, or using a binary archive that was created
on a different architecture (sent data through network?), ...,
but none of that is in your code example. if you're not using old
archives created by other code: no idea.
however, since you seem to also serialize individual objects, you
might be interested in this archive: http://pastebin.com/PTdRE8tR
it serializes objects directly to a std::vector<char> or any
other char container, circumventing streams. The Serialization
library is only invoked on demand, if your objects are track_never
and object_serializable no Serialization archive is constructed.
constructing a binary_oarchive for each object can be quite
expensive (codecvt construction, pimpl construction, archive
internals for pointer tracking, ...)
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users