diff --git a/applications/test/OStringStream/Test-OStringStream.C b/applications/test/OStringStream/Test-OStringStream.C index e83cc396b9..28e3861e47 100644 --- a/applications/test/OStringStream/Test-OStringStream.C +++ b/applications/test/OStringStream/Test-OStringStream.C @@ -52,9 +52,11 @@ int main(int argc, char *argv[]) Info<< "overwrite with short string:" << nl << os.str() << endl; -// os.reset(); -// Info<< "after reset:" << nl -// << os.str() << endl; + os.reset(); + os << "%%%% reset"; + + Info<< "after reset:" << nl + << os.str() << endl; Info<< "End\n" << endl; diff --git a/applications/test/error/Test-error.C b/applications/test/error/Test-error.C index b9be1924a5..981e071b8f 100644 --- a/applications/test/error/Test-error.C +++ b/applications/test/error/Test-error.C @@ -47,8 +47,24 @@ int main(int argc, char *argv[]) IOWarningInFunction(dict) << "warning 3" << endl; - FatalErrorInFunction << "error 1" << endl; - FatalErrorInFunction << "error 2" << exit(FatalError); + FatalErrorInFunction + << "This is an error from 1" << nl + << "Explanation to follow:" << endl; + + FatalErrorInFunction + << "Error 2" + << exit(FatalError); + } + catch (Foam::error& fErr) + { + Serr<< "Caught Foam error " << fErr << nl << endl; + } + + try + { + FatalErrorInFunction + << "Error# 3" + << exit(FatalError); } catch (Foam::error& fErr) { diff --git a/applications/test/sha1/Test-SHA1.C b/applications/test/sha1/Test-SHA1.C index 8ec679accd..03062d8596 100644 --- a/applications/test/sha1/Test-SHA1.C +++ b/applications/test/sha1/Test-SHA1.C @@ -96,7 +96,7 @@ int main(int argc, char * argv[]) os << str; Info<< os.digest() << endl; - os.rewind(); + os.reset(); os << "The quick brown fox jumps over the lazy dog"; Info<< os.digest() << endl; } diff --git a/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H b/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H index 1e26a65092..3f50c2fac7 100644 --- a/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H +++ b/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H @@ -223,6 +223,13 @@ public: // Member Functions + //- Reset the output buffer and rewind the stream + void reset() + { + this->str(""); // No other way to reset the end + this->rewind(); + } + //- Rewind the output stream void rewind() { diff --git a/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H b/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H index aae7efe720..8a43d3d7b1 100644 --- a/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H +++ b/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H @@ -226,7 +226,7 @@ public: // Access //- Return SHA1::Digest for the data processed until now - Foam::SHA1Digest digest() + SHA1Digest digest() { return sha1().digest(); } @@ -235,6 +235,13 @@ public: // Edit //- Clear the SHA1 calculation + void reset() + { + sha1().clear(); + } + + //- Clear the SHA1 calculation + // \deprecated use reset instead (deprecated Jul 2017) void rewind() { sha1().clear(); diff --git a/src/OpenFOAM/db/error/IOerror.C b/src/OpenFOAM/db/error/IOerror.C index aa7cbda539..4e2fab2e0e 100644 --- a/src/OpenFOAM/db/error/IOerror.C +++ b/src/OpenFOAM/db/error/IOerror.C @@ -193,8 +193,8 @@ void Foam::IOerror::exit(const int) // Make a copy of the error to throw IOerror errorException(*this); - // Rewind the message buffer for the next error message - messageStreamPtr_->rewind(); + // Reset the message buffer for the next error message + messageStreamPtr_->reset(); throw errorException; } @@ -238,8 +238,8 @@ void Foam::IOerror::abort() // Make a copy of the error to throw IOerror errorException(*this); - // Rewind the message buffer for the next error message - messageStreamPtr_->rewind(); + // Reset the message buffer for the next error message + messageStreamPtr_->reset(); throw errorException; } diff --git a/src/OpenFOAM/db/error/error.C b/src/OpenFOAM/db/error/error.C index a5c049f1b4..e0dbff97d8 100644 --- a/src/OpenFOAM/db/error/error.C +++ b/src/OpenFOAM/db/error/error.C @@ -188,8 +188,8 @@ void Foam::error::exit(const int errNo) // Make a copy of the error to throw error errorException(*this); - // Rewind the message buffer for the next error message - messageStreamPtr_->rewind(); + // Reset the message buffer for the next error message + messageStreamPtr_->reset(); throw errorException; } @@ -233,8 +233,8 @@ void Foam::error::abort() // Make a copy of the error to throw error errorException(*this); - // Rewind the message buffer for the next error message - messageStreamPtr_->rewind(); + // Reset the message buffer for the next error message + messageStreamPtr_->reset(); throw errorException; }