Boost logo

Boost Users :

Subject: Re: [Boost-users] binary archive with text file
From: gtsml owevwr (gtsml.owevwr_at_[hidden])
Date: 2009-01-12 05:00:52


Thanks for your quick answer. Looks like you found a hole in the standard
library... I'm sure boost can fix that :-)
Maybe there's a way to detect if it's binary or not by writing something
dumb and check the current postion. An "active probe" if I may.

Thanks,
Frank

PS: Couple of more keywords so that somebody with the same problem find this
post: serialization, bug, issue, exception, binary mode, open mode.
Btw, the problem was not descrribe with human words:
Opening a binary archive with a non-binary stream leads to an exception
which looks unrelated to the origin of the problem (which makes it hard to
debug).

On Fri, Jan 9, 2009 at 8:26 PM, Robert Ramey <ramey_at_[hidden]> wrote:

> I've been aware of this since the very beginning.
>
> If you have a way of determining the flags which have been set on
> and open stream - please let me know.
>
> Robert Ramey
>
> "gtsml owevwr" <gtsml.owevwr_at_[hidden]> wrote in message
> news:6e954aa60901090542v4fe9be4w5993fabe0e1e6c53_at_mail.gmail.com...
> Hi,
>
> I just spend a entire day to realize this code was wrong:
>
> std::ofstream ofs(filename.c_str());
> boost::archive::binary_ oarchive oa(ofs);
> oa << (*this);
>
> And this one was right:
>
> std::ofstream ofs(filename.c_str(), std::ios::binary);
> boost::archive::binary_oarchive oa(ofs);
> oa << (*this);
>
>
> The consequence of the first code is a "stream_error" throw which doesn't
> say much about the problem.
> Instead, an exception should be thrown earlier on if the file is not in
> binary mode.
>
> thanks alot to all the boost contributors,
> Frank
>
> ------------------------------
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net