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:
Mark Olesen
2017-07-17 15:14:38 +02:00
parent b0db30ba2f
commit 86ef9e86dc
112 changed files with 708 additions and 624 deletions

View File

@ -24,7 +24,6 @@ License
\*---------------------------------------------------------------------------*/
#include "ensightReadFile.H"
#include <sstream>
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "NASCore.H"
#include "IStringStream.H"
#include "StringStream.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

View File

@ -27,7 +27,7 @@ License
#include "ListOps.H"
#include "clock.H"
#include "PackedBoolList.H"
#include "IStringStream.H"
#include "StringStream.H"
#include "OSspecific.H"

View File

@ -89,9 +89,9 @@ int Foam::fileFormats::STLCore::detectBinaryHeader
)
{
bool compressed = false;
autoPtr<istream> streamPtr
autoPtr<std::istream> streamPtr
(
new ifstream(filename.c_str(), std::ios::binary)
new std::ifstream(filename, std::ios::binary)
);
// If the file is compressed, decompress it before further checking.
@ -100,7 +100,7 @@ int Foam::fileFormats::STLCore::detectBinaryHeader
compressed = true;
streamPtr.reset(new igzstream((filename + ".gz").c_str()));
}
istream& is = streamPtr();
std::istream& is = streamPtr();
if (!is.good())
{
@ -165,9 +165,9 @@ Foam::fileFormats::STLCore::readBinaryHeader
bool compressed = false;
nTrisEstimated = 0;
autoPtr<istream> streamPtr
autoPtr<std::istream> streamPtr
(
new ifstream(filename.c_str(), std::ios::binary)
new std::ifstream(filename, std::ios::binary)
);
// If the file is compressed, decompress it before reading.
@ -176,7 +176,7 @@ Foam::fileFormats::STLCore::readBinaryHeader
compressed = true;
streamPtr.reset(new igzstream((filename + ".gz").c_str()));
}
istream& is = streamPtr();
std::istream& is = streamPtr();
if (!is.good())
{