mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: make treatment of stream allocators more uniform (issue #532)
- use allocator class to wrap the stream pointers instead of passing them into ISstream, OSstream and using a dynamic cast to delete then. This is especially important if we will have a bidirectional stream (can't delete twice!). STYLE: - file stream constructors with std::string (C++11) - for rewind, explicit about in|out direction. This is not currently important, but avoids surprises with any future bidirectional access. - combined string streams in StringStream.H header. Similar to <sstream> include that has both input and output string streams.
This commit is contained in:
@ -25,8 +25,8 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OStringStream.H"
|
||||
#include "IOstreams.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -35,15 +35,26 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "khkj" << endl;
|
||||
Info<< "Begin test OStringStream" << endl;
|
||||
|
||||
OStringStream testStream;
|
||||
testStream << "hello " << 1 << endl;
|
||||
Info<< testStream.str() << endl;
|
||||
testStream.rewind();
|
||||
Info<< testStream.str() << endl;
|
||||
testStream << "hello " << 2 << endl;
|
||||
Info<< testStream.str() << endl;
|
||||
OStringStream os;
|
||||
os << "output with some values " << 1 << " entry" << endl;
|
||||
|
||||
Info<< "contains:" << nl
|
||||
<< os.str() << endl;
|
||||
os.rewind();
|
||||
|
||||
Info<< "after rewind:" << nl
|
||||
<< os.str() << endl;
|
||||
|
||||
os << "####";
|
||||
|
||||
Info<< "overwrite with short string:" << nl
|
||||
<< os.str() << endl;
|
||||
|
||||
// os.reset();
|
||||
// Info<< "after reset:" << nl
|
||||
// << os.str() << endl;
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user