|
Boost Users : |
From: Martin Slater (mslater_at_[hidden])
Date: 2005-09-14 18:24:11
Jonathan Turkanis wrote:
>>Just to be sure, were using an old version with boost 1.32 where
>>stream == source.
>
>
> I don't think stream was ever equivalent to source.
My bad, sorry, I didnt have the code in front of me.
>>the only way we have of reporting an error is
>>through an exception but this doesn't get caught and translated by the
>>stream_facade but propogated straight out to our code.
>
>
> stream_facade doesn't catch and rethrow exceptions which occur during open().
> You can change this by modifying stream_facade::open_impl so that it looks
> something like the following (I'm not sure exactly what the code in your version
> looks like):
>
> void open_impl(const Device& dev BOOST_IOSTREAMS_PUSH_PARAMS())
> {
> this->clear();
> try {
> this->member.open(dev BOOST_IOSTREAMS_PUSH_ARGS());
> } catch(...) {
> this->clear(std::ios_base::badbit);
> if (this->exceptions() & std::ios_base::badbit)
> throw;
> }
> }
>
> Alternatively, you could give your Source a member function 'good' returning a
> bool, and do
>
> stream_facade< random_source > in( random_source(888) );
> if (in->good()) {
> ...
> }
>
> Lastly, you could set a flag in the constructor and have subsequent read or
> write requests fail is the construction was unsuccessful.
>
> I'll consider adding the above code to open_impl() for 1.34 (or maybe 1.33.1,
> since it seems like a harmless change, and improves usability). Thanks for
> bringing this to my attention.
Thanks for all the details i'll make your suggested change locally.
Getting it in 1.33.1 would get my vote as the behaviour as is is
surprising. Anyway an extremely useful library , thanks for all the good
work.
Martin
-- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.10.25/102 - Release Date: 14/09/2005
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