Commit ed4bd548 authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: provide return value for IOstream::fatalCheck()

- allows reuse as base implementation for IOstream::check()
parent ac709da3
......@@ -50,25 +50,22 @@ Foam::fileName& Foam::IOstream::name()
bool Foam::IOstream::check(const char* operation) const
{
if (bad())
{
FatalIOErrorInFunction(*this)
<< "error in IOstream " << name() << " for operation " << operation
<< exit(FatalIOError);
}
return !bad();
return fatalCheck(operation);
}
void Foam::IOstream::fatalCheck(const char* operation) const
bool Foam::IOstream::fatalCheck(const char* operation) const
{
if (bad())
const bool ok = !bad();
if (!ok)
{
FatalIOErrorInFunction(*this)
<< "error in IOstream " << name() << " for operation " << operation
<< exit(FatalIOError);
}
return ok;
}
......
......@@ -199,12 +199,14 @@ public:
// Check
//- Check IOstream status for given operation.
// Print IOstream state if error has occurred
// Print IOstream state or generate a FatalIOError
// when an error has occurred.
// The base implementation is a fatalCheck
virtual bool check(const char* operation) const;
//- Check IOstream status for given operation.
// Print IOstream state if error has occurred and exit
void fatalCheck(const char* operation) const;
// Generate a FatalIOError when an error has occurred.
bool fatalCheck(const char* operation) const;
//- Return true if stream has been opened
bool opened() const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment