|
Boost : |
From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-01-20 08:30:59
Robert Ramey wrote:
> Vladimir Prus worte:
>
>>A solution that would be fine with me is to have a way to tell if
>>exception is thrown because of eof, or other reasons. What do you think?
>
> if thats all you want just check eofbit on the stream after the
> stream_error exception is caught.
I think this way I'll ignore errors where serialization lib started reading
object data and find eof in the middle. This situation means archive is
corrupt, and it's better to diagnose it.
Consider standard iostream usage
string s;
while(getline(is, s)) {
}
Here, two cases are possible when getline returns false. First is when eof
is seen, in which case line is done. Second is when something's really
wrong with the stream, in which case badbit is set. For serialization
some_object obj;
while(ia >> obj) {
}
there's possibility that data ended half-way though next object. How can I
tell if that's the case?
- Volodya
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk