Skip to content
Snippets Groups Projects
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
Branches
Tags
No related merge requests found
...@@ -50,25 +50,22 @@ Foam::fileName& Foam::IOstream::name() ...@@ -50,25 +50,22 @@ Foam::fileName& Foam::IOstream::name()
bool Foam::IOstream::check(const char* operation) const bool Foam::IOstream::check(const char* operation) const
{ {
if (bad()) return fatalCheck(operation);
{
FatalIOErrorInFunction(*this)
<< "error in IOstream " << name() << " for operation " << operation
<< exit(FatalIOError);
}
return !bad();
} }
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) FatalIOErrorInFunction(*this)
<< "error in IOstream " << name() << " for operation " << operation << "error in IOstream " << name() << " for operation " << operation
<< exit(FatalIOError); << exit(FatalIOError);
} }
return ok;
} }
......
...@@ -199,12 +199,14 @@ public: ...@@ -199,12 +199,14 @@ public:
// Check // Check
//- Check IOstream status for given operation. //- 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; virtual bool check(const char* operation) const;
//- Check IOstream status for given operation. //- Check IOstream status for given operation.
// Print IOstream state if error has occurred and exit // Generate a FatalIOError when an error has occurred.
void fatalCheck(const char* operation) const; bool fatalCheck(const char* operation) const;
//- Return true if stream has been opened //- Return true if stream has been opened
bool opened() const bool opened() const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment