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

@ -46,7 +46,7 @@ Description
#include <cstdio>
#include "scalar.H"
#include "IStringStream.H"
#include "StringStream.H"
using namespace Foam;
@ -271,7 +271,6 @@ elementType ^{space}"TYPE"{cspace}
#include "fileName.H"
#include <fstream>
using std::ifstream;
label findFace(const polyMesh& mesh, const face& f)
@ -318,8 +317,8 @@ int main(int argc, char *argv[])
#include "createTime.H"
fileName ansysFile(args[1]);
ifstream ansysStream(ansysFile.c_str());
const fileName ansysFile(args[1]);
std::ifstream ansysStream(ansysFile);
if (!ansysStream)
{

View File

@ -58,7 +58,7 @@ int main(int argc, char *argv[])
#include "createTime.H"
std::ifstream plot3dFile(args[1].c_str());
std::ifstream plot3dFile(args[1]);
string line;
std::getline(plot3dFile, line);

View File

@ -43,7 +43,7 @@ Description
#include "argList.H"
#include "Time.H"
#include "IStringStream.H"
#include "StringStream.H"
#include "polyMesh.H"
#include "emptyPolyPatch.H"
#include "wallPolyPatch.H"
@ -906,7 +906,7 @@ int main(int argc, char *argv[])
#include "createTime.H"
const fileName fluentFile = args[1];
std::ifstream fluentStream(fluentFile.c_str());
std::ifstream fluentStream(fluentFile);
if (!fluentStream)
{

View File

@ -26,7 +26,6 @@ License
#include <fstream>
#include <iostream>
using std::ofstream;
using std::ios;
#include "Time.H"
@ -49,18 +48,16 @@ Foam::fluentFvMesh::fluentFvMesh(const IOobject& io)
void Foam::fluentFvMesh::writeFluentMesh() const
{
// make a directory called proInterface in the case
// Make a directory called fluentInterface in the case
mkDir(time().rootPath()/time().caseName()/"fluentInterface");
// open a file for the mesh
ofstream fluentMeshFile
// Open a file for the mesh
std::ofstream fluentMeshFile
(
(
time().rootPath()/
time().caseName()/
"fluentInterface"/
time().caseName() + ".msh"
).c_str()
time().rootPath()
/ time().caseName()
/ "fluentInterface"
/ time().caseName() + ".msh"
);
Info<< "Writing Header" << endl;

View File

@ -41,7 +41,7 @@ Description
\* ------------------------------------------------------------------------- */
#include "scalarList.H"
#include "IStringStream.H"
#include "StringStream.H"
// For EOF only
#include <cstdio>
@ -622,7 +622,6 @@ mtype {space}"MTYPE:"{space}
#include "fileName.H"
#include <fstream>
using std::ifstream;
int main(int argc, char *argv[])
{
@ -647,7 +646,7 @@ int main(int argc, char *argv[])
#include "createTime.H"
const fileName gambitFile = args[1];
ifstream gambitStream(gambitFile.c_str());
std::ifstream gambitStream(gambitFile);
if (!gambitStream)
{

View File

@ -1,4 +1,4 @@
ifstream kivaFile(kivaFileName.c_str());
std::ifstream kivaFile(kivaFileName);
if (!kivaFile.good())
{

View File

@ -27,8 +27,7 @@ License
#include "point.H"
#include "Istream.H"
#include "Ostream.H"
#include "OStringStream.H"
#include "IStringStream.H"
#include "StringStream.H"
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //

View File

@ -36,7 +36,6 @@ Description
#include "argList.H"
#include "fvMesh.H"
#include "pointFields.H"
#include "IStringStream.H"
#include "volPointInterpolation.H"
using namespace Foam;

View File

@ -34,16 +34,12 @@ Description
#include "argList.H"
#include "OFstream.H"
#include <fstream>
#include <sstream>
#include "IStringStream.H"
#include "StringStream.H"
#include "point.H"
#include "DynamicList.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
string getLine(std::ifstream& is)
@ -122,7 +118,7 @@ int main(int argc, char *argv[])
const fileName objName = args[1];
const fileName outName = args[2];
std::ifstream OBJfile(objName.c_str());
std::ifstream OBJfile(objName);
if (!OBJfile.good())
{

View File

@ -36,7 +36,7 @@ Description
#include "Time.H"
#include "polyMesh.H"
#include "globalMeshData.H"
#include "IStringStream.H"
#include "StringStream.H"
#include "cellSet.H"
#include "faceSet.H"
#include "pointSet.H"

View File

@ -46,12 +46,9 @@ Description
#include "argList.H"
#include "Time.H"
#include "polyMesh.H"
#include "IStringStream.H"
#include "cellSet.H"
#include "faceSet.H"
#include "pointSet.H"
#include "OFstream.H"
#include "IFstream.H"
#include "IOobjectList.H"
#include "SortableList.H"
#include "timeSelector.H"

View File

@ -68,7 +68,7 @@ Usage
#include "pointFields.H"
#include "transformField.H"
#include "transformGeometricField.H"
#include "IStringStream.H"
#include "StringStream.H"
#include "mathematicalConstants.H"
using namespace Foam;