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:
Mark Olesen
2017-07-17 18:32:42 +02:00
parent 86ef9e86dc
commit b4b50a3aa8
7 changed files with 47 additions and 15 deletions

View File

@ -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;

View File

@ -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)
{

View File

@ -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;
}