Addin exceptions in SvStream

Marc-André Laverdière marcandre.laverdiere at gmail.com
Mon Dec 10 07:27:11 PST 2012


Hello everyone,

I am doing some proactive hardening of the image filters these days,
and I have to say that there is a lot of code like this:

*stream >> meh;
if (! stream->good())
  return sal_False;

It is very cluttered to do this for _every_ read.

A simpler way would be to have opt-in exception handling. Here is how
that would work.

By default, all SvStreams _do not_ throw exceptions.

However, we could have a call like
stream->setThrowExceptions(sal_True) to enable them and then
stream->setThrowExceptions(sal_True) to disable them once the bit of
code that is aware of exceptions is done.
That means that we need a call stream->getThrowExceptions() to handle this.

The only risk I can see is if svstreams are accessed in a
multithreaded manner. I don't know of any case like that.

Another way to implement this would be with a wrapper class such as
ExceptionSvStream that would have the same interface, so that it can
be dropped in wherever needed.

What do you think of these proposals? What could go wrong if we were
to implement it?

Regards,

Marc-André LAVERDIÈRE
"Perseverance must finish its work so that you may be mature and complete,
not lacking anything." -James 1:4
http://asimplediscipleslife.blogspot.com/
mlaverd.theunixplace.com


More information about the LibreOffice mailing list