mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: added OStringStream reset method (closes #534)
- resets the output buffer completely - implementing what rewind was likely meant to have accomplished for many use cases. STYLE: OSHA1stream reset() for symmetry. Deprecate rewind().
This commit is contained in:
@ -52,9 +52,11 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "overwrite with short string:" << nl
|
Info<< "overwrite with short string:" << nl
|
||||||
<< os.str() << endl;
|
<< os.str() << endl;
|
||||||
|
|
||||||
// os.reset();
|
os.reset();
|
||||||
// Info<< "after reset:" << nl
|
os << "%%%% reset";
|
||||||
// << os.str() << endl;
|
|
||||||
|
Info<< "after reset:" << nl
|
||||||
|
<< os.str() << endl;
|
||||||
|
|
||||||
Info<< "End\n" << endl;
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
|
|||||||
@ -47,8 +47,24 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
IOWarningInFunction(dict) << "warning 3" << endl;
|
IOWarningInFunction(dict) << "warning 3" << endl;
|
||||||
|
|
||||||
FatalErrorInFunction << "error 1" << endl;
|
FatalErrorInFunction
|
||||||
FatalErrorInFunction << "error 2" << exit(FatalError);
|
<< "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)
|
catch (Foam::error& fErr)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -96,7 +96,7 @@ int main(int argc, char * argv[])
|
|||||||
os << str;
|
os << str;
|
||||||
Info<< os.digest() << endl;
|
Info<< os.digest() << endl;
|
||||||
|
|
||||||
os.rewind();
|
os.reset();
|
||||||
os << "The quick brown fox jumps over the lazy dog";
|
os << "The quick brown fox jumps over the lazy dog";
|
||||||
Info<< os.digest() << endl;
|
Info<< os.digest() << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -223,6 +223,13 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// 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
|
//- Rewind the output stream
|
||||||
void rewind()
|
void rewind()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -226,7 +226,7 @@ public:
|
|||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Return SHA1::Digest for the data processed until now
|
//- Return SHA1::Digest for the data processed until now
|
||||||
Foam::SHA1Digest digest()
|
SHA1Digest digest()
|
||||||
{
|
{
|
||||||
return sha1().digest();
|
return sha1().digest();
|
||||||
}
|
}
|
||||||
@ -235,6 +235,13 @@ public:
|
|||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
//- Clear the SHA1 calculation
|
//- Clear the SHA1 calculation
|
||||||
|
void reset()
|
||||||
|
{
|
||||||
|
sha1().clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Clear the SHA1 calculation
|
||||||
|
// \deprecated use reset instead (deprecated Jul 2017)
|
||||||
void rewind()
|
void rewind()
|
||||||
{
|
{
|
||||||
sha1().clear();
|
sha1().clear();
|
||||||
|
|||||||
@ -193,8 +193,8 @@ void Foam::IOerror::exit(const int)
|
|||||||
// Make a copy of the error to throw
|
// Make a copy of the error to throw
|
||||||
IOerror errorException(*this);
|
IOerror errorException(*this);
|
||||||
|
|
||||||
// Rewind the message buffer for the next error message
|
// Reset the message buffer for the next error message
|
||||||
messageStreamPtr_->rewind();
|
messageStreamPtr_->reset();
|
||||||
|
|
||||||
throw errorException;
|
throw errorException;
|
||||||
}
|
}
|
||||||
@ -238,8 +238,8 @@ void Foam::IOerror::abort()
|
|||||||
// Make a copy of the error to throw
|
// Make a copy of the error to throw
|
||||||
IOerror errorException(*this);
|
IOerror errorException(*this);
|
||||||
|
|
||||||
// Rewind the message buffer for the next error message
|
// Reset the message buffer for the next error message
|
||||||
messageStreamPtr_->rewind();
|
messageStreamPtr_->reset();
|
||||||
|
|
||||||
throw errorException;
|
throw errorException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -188,8 +188,8 @@ void Foam::error::exit(const int errNo)
|
|||||||
// Make a copy of the error to throw
|
// Make a copy of the error to throw
|
||||||
error errorException(*this);
|
error errorException(*this);
|
||||||
|
|
||||||
// Rewind the message buffer for the next error message
|
// Reset the message buffer for the next error message
|
||||||
messageStreamPtr_->rewind();
|
messageStreamPtr_->reset();
|
||||||
|
|
||||||
throw errorException;
|
throw errorException;
|
||||||
}
|
}
|
||||||
@ -233,8 +233,8 @@ void Foam::error::abort()
|
|||||||
// Make a copy of the error to throw
|
// Make a copy of the error to throw
|
||||||
error errorException(*this);
|
error errorException(*this);
|
||||||
|
|
||||||
// Rewind the message buffer for the next error message
|
// Reset the message buffer for the next error message
|
||||||
messageStreamPtr_->rewind();
|
messageStreamPtr_->reset();
|
||||||
|
|
||||||
throw errorException;
|
throw errorException;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user