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:
@ -31,8 +31,7 @@ Description
|
||||
|
||||
#include "CompactListList.H"
|
||||
#include "IOstreams.H"
|
||||
#include "OStringStream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "faceList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -29,8 +29,7 @@ License
|
||||
#include "DynamicList.H"
|
||||
#include "FlatOutput.H"
|
||||
#include "IOstreams.H"
|
||||
#include "IStringStream.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "wordList.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ See also
|
||||
#include "wordReList.H"
|
||||
|
||||
#include "IOstreams.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "scalar.H"
|
||||
#include "vector.H"
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ Description
|
||||
#include "uLabel.H"
|
||||
#include "IOstreams.H"
|
||||
#include "PackedBoolList.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "Polynomial.H"
|
||||
#include "polynomialFunction.H"
|
||||
#include "Random.H"
|
||||
|
||||
@ -25,8 +25,7 @@ License
|
||||
|
||||
#include "StaticHashTable.H"
|
||||
#include "IOstreams.H"
|
||||
#include "IStringStream.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -26,7 +26,6 @@ License
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "fvMesh.H"
|
||||
#include "IStringStream.H"
|
||||
#include "indexedOctree.H"
|
||||
#include "treeDataCell.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
@ -26,7 +26,6 @@ License
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "fvMesh.H"
|
||||
#include "IStringStream.H"
|
||||
#include "indexedOctree.H"
|
||||
#include "treeDataEdge.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
@ -34,8 +34,6 @@ Description
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "IOstreams.H"
|
||||
#include "OStringStream.H"
|
||||
#include "IStringStream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -31,7 +31,6 @@ Description
|
||||
#include "OSspecific.H"
|
||||
|
||||
#include "IOstreams.H"
|
||||
#include "IStringStream.H"
|
||||
#include "scalar.H"
|
||||
#include "vector.H"
|
||||
#include "ListOps.H"
|
||||
@ -49,31 +48,26 @@ int main(int argc, char *argv[])
|
||||
|
||||
//Pout.prefix() = '[' + name(Pstream::myProcNo()) + "] ";
|
||||
|
||||
List<vector> list(IStringStream("1 ((0 1 2))")());
|
||||
List<vector> list{{0, 1, 2}};
|
||||
Info<< list << endl;
|
||||
|
||||
List<vector> list2
|
||||
(
|
||||
IStringStream
|
||||
(
|
||||
"(\
|
||||
(0 1 2)\
|
||||
(3 4 5)\
|
||||
(3 4 5)\
|
||||
(3 4 5)\
|
||||
(3 4 5)\
|
||||
(3 4 5)\
|
||||
(3 4 5)\
|
||||
(3 4 5)\
|
||||
(3 4 5)\
|
||||
(3 4 5)\
|
||||
(3 4 5)\
|
||||
(3 4 5)\
|
||||
(3 4 5)\
|
||||
(3 4 5)\
|
||||
)"
|
||||
)()
|
||||
);
|
||||
{
|
||||
{0, 1, 2},
|
||||
{3, 4, 5},
|
||||
{3, 4, 5},
|
||||
{3, 4, 5},
|
||||
{3, 4, 5},
|
||||
{3, 4, 5},
|
||||
{3, 4, 5},
|
||||
{3, 4, 5},
|
||||
{3, 4, 5},
|
||||
{3, 4, 5},
|
||||
{3, 4, 5},
|
||||
{3, 4, 5},
|
||||
{3, 4, 5},
|
||||
{3, 4, 5},
|
||||
};
|
||||
Pout<< list2 << endl;
|
||||
|
||||
Info<< findIndex(list2, vector(3, 4, 5)) << endl;
|
||||
|
||||
@ -28,10 +28,8 @@ Description
|
||||
#include "argList.H"
|
||||
#include "label.H"
|
||||
#include "labelList.H"
|
||||
#include "OStringStream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "OFstream.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "point.H"
|
||||
#include "Time.H"
|
||||
#include "fvMesh.H"
|
||||
|
||||
@ -30,7 +30,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OSHA1stream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -32,7 +32,6 @@ Description
|
||||
#include "dictionary.H"
|
||||
#include "nil.H"
|
||||
#include "IOstreams.H"
|
||||
#include "IStringStream.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
@ -26,8 +26,8 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "stringListOps.H"
|
||||
#include "IStringStream.H"
|
||||
#include "IOstreams.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -37,22 +37,17 @@ using namespace Foam;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
stringList strLst
|
||||
(
|
||||
IStringStream
|
||||
(
|
||||
"("
|
||||
"\"hello\""
|
||||
"\"heello\""
|
||||
"\"heeello\""
|
||||
"\"bye\""
|
||||
"\"bbye\""
|
||||
"\"bbbye\""
|
||||
"\"okey\""
|
||||
"\"okkey\""
|
||||
"\"okkkey\""
|
||||
")"
|
||||
)()
|
||||
);
|
||||
{
|
||||
"hello",
|
||||
"heello",
|
||||
"heeello",
|
||||
"bye",
|
||||
"bbye",
|
||||
"bbbye",
|
||||
"okey",
|
||||
"okkey",
|
||||
"okkkey",
|
||||
};
|
||||
|
||||
wordReList reLst(IStringStream("( okey \"[hy]e+.*\" )")());
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ Description
|
||||
#include "IOobject.H"
|
||||
#include "IOstreams.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "cpuTime.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -30,7 +30,6 @@ Description
|
||||
#include "OSspecific.H"
|
||||
|
||||
#include "IOstreams.H"
|
||||
#include "IStringStream.H"
|
||||
#include "labelList.H"
|
||||
#include "DynamicList.H"
|
||||
#include "face.H"
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
ifstream kivaFile(kivaFileName.c_str());
|
||||
std::ifstream kivaFile(kivaFileName);
|
||||
|
||||
if (!kivaFile.good())
|
||||
{
|
||||
|
||||
@ -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 * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -36,7 +36,6 @@ Description
|
||||
#include "argList.H"
|
||||
#include "fvMesh.H"
|
||||
#include "pointFields.H"
|
||||
#include "IStringStream.H"
|
||||
#include "volPointInterpolation.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -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())
|
||||
{
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -31,7 +31,7 @@ License
|
||||
#include "blockMeshTools.H"
|
||||
#include "Time.H"
|
||||
#include "patchZones.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
#include "boundaryTemplates.H"
|
||||
#include "Time.H"
|
||||
#include "IFstream.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -71,8 +71,7 @@ Note
|
||||
#include "ModifiableMeshedSurface.H"
|
||||
#include "UnsortedMeshedSurfaces.H"
|
||||
|
||||
#include "IStringStream.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -36,8 +36,7 @@ Description
|
||||
#include "argList.H"
|
||||
#include "chemkinReader.H"
|
||||
#include "OFstream.H"
|
||||
#include "OStringStream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -724,13 +724,13 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
|
||||
}
|
||||
|
||||
// Open and check streams.
|
||||
std::ifstream srcStream(src.c_str());
|
||||
std::ifstream srcStream(src);
|
||||
if (!srcStream)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ofstream destStream(destFile.c_str());
|
||||
std::ofstream destStream(destFile);
|
||||
if (!destStream)
|
||||
{
|
||||
return false;
|
||||
|
||||
@ -24,9 +24,9 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
#include "OStringStream.H"
|
||||
#include "OSspecific.H"
|
||||
#include "IFstream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <cxxabi.h>
|
||||
@ -55,7 +55,7 @@ string pOpen(const string &cmd, label line=0)
|
||||
{
|
||||
size_t linecap = 0;
|
||||
ssize_t linelen;
|
||||
linelen = getline(&buf, &linecap, cmdPipe);
|
||||
linelen = ::getline(&buf, &linecap, cmdPipe);
|
||||
|
||||
if (linelen < 0)
|
||||
{
|
||||
|
||||
@ -171,7 +171,7 @@ Tstreams = $(Streams)/Tstreams
|
||||
$(Tstreams)/ITstream.C
|
||||
|
||||
StringStreams = $(Streams)/StringStreams
|
||||
$(StringStreams)/StringStreamsPrint.C
|
||||
$(StringStreams)/StringStream.C
|
||||
|
||||
Pstreams = $(Streams)/Pstreams
|
||||
$(Pstreams)/UIPstream.C
|
||||
|
||||
40
src/OpenFOAM/db/IOstreams/Fstreams/Fstream.H
Normal file
40
src/OpenFOAM/db/IOstreams/Fstreams/Fstream.H
Normal file
@ -0,0 +1,40 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
InClass
|
||||
Foam::Fstream
|
||||
|
||||
Description
|
||||
Input/output from file streams.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Fstream_H
|
||||
#define Fstream_H
|
||||
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,11 +35,11 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
|
||||
:
|
||||
ifPtr_(nullptr),
|
||||
allocatedPtr_(nullptr),
|
||||
compression_(IOstream::UNCOMPRESSED)
|
||||
{
|
||||
if (pathname.empty())
|
||||
@ -50,21 +50,21 @@ Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
|
||||
}
|
||||
}
|
||||
|
||||
ifPtr_ = new ifstream(pathname.c_str());
|
||||
allocatedPtr_ = new std::ifstream(pathname);
|
||||
|
||||
// If the file is compressed, decompress it before reading.
|
||||
if (!ifPtr_->good() && isFile(pathname + ".gz", false))
|
||||
if (!allocatedPtr_->good() && isFile(pathname + ".gz", false))
|
||||
{
|
||||
if (IFstream::debug)
|
||||
{
|
||||
InfoInFunction << "Decompressing " << pathname + ".gz" << endl;
|
||||
}
|
||||
|
||||
delete ifPtr_;
|
||||
delete allocatedPtr_;
|
||||
|
||||
ifPtr_ = new igzstream((pathname + ".gz").c_str());
|
||||
allocatedPtr_ = new igzstream((pathname + ".gz").c_str());
|
||||
|
||||
if (ifPtr_->good())
|
||||
if (allocatedPtr_->good())
|
||||
{
|
||||
compression_ = IOstream::COMPRESSED;
|
||||
}
|
||||
@ -72,9 +72,23 @@ Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::IFstreamAllocator::~IFstreamAllocator()
|
||||
{
|
||||
delete ifPtr_;
|
||||
deallocate();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::IFstreamAllocator::deallocate()
|
||||
{
|
||||
if (allocatedPtr_)
|
||||
{
|
||||
delete allocatedPtr_;
|
||||
allocatedPtr_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -90,7 +104,7 @@ Foam::IFstream::IFstream
|
||||
IFstreamAllocator(pathname),
|
||||
ISstream
|
||||
(
|
||||
*ifPtr_,
|
||||
*allocatedPtr_,
|
||||
pathname,
|
||||
format,
|
||||
version,
|
||||
@ -99,14 +113,15 @@ Foam::IFstream::IFstream
|
||||
{
|
||||
setClosed();
|
||||
|
||||
setState(ifPtr_->rdstate());
|
||||
setState(allocatedPtr_->rdstate());
|
||||
|
||||
if (!good())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction
|
||||
<< "Could not open file for input" << endl << info() << endl;
|
||||
<< "Could not open file " << pathname
|
||||
<< " for input" << nl << info() << Foam::endl;
|
||||
}
|
||||
|
||||
setBad();
|
||||
@ -130,29 +145,30 @@ Foam::IFstream::~IFstream()
|
||||
|
||||
std::istream& Foam::IFstream::stdStream()
|
||||
{
|
||||
if (!ifPtr_)
|
||||
if (!allocatedPtr_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "No stream allocated" << abort(FatalError);
|
||||
<< "No stream allocated"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
return *ifPtr_;
|
||||
return *allocatedPtr_;
|
||||
}
|
||||
|
||||
|
||||
const std::istream& Foam::IFstream::stdStream() const
|
||||
{
|
||||
if (!ifPtr_)
|
||||
if (!allocatedPtr_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "No stream allocated" << abort(FatalError);
|
||||
<< "No stream allocated"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
return *ifPtr_;
|
||||
return *allocatedPtr_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::IFstream::print(Ostream& os) const
|
||||
{
|
||||
// Print File data
|
||||
os << "IFstream: ";
|
||||
ISstream::print(os);
|
||||
}
|
||||
@ -164,10 +180,10 @@ Foam::IFstream& Foam::IFstream::operator()() const
|
||||
{
|
||||
if (!good())
|
||||
{
|
||||
// also checks .gz file
|
||||
// Also checks .gz file
|
||||
if (isFile(this->name(), true))
|
||||
{
|
||||
check("IFstream::operator()");
|
||||
check(FUNCTION_NAME);
|
||||
FatalIOError.exit();
|
||||
}
|
||||
else
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::IFstream
|
||||
|
||||
Description
|
||||
Input from file stream.
|
||||
Input from file stream, using a ISstream
|
||||
|
||||
SourceFiles
|
||||
IFstream.C
|
||||
@ -47,20 +47,21 @@ using std::ifstream;
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class IFstream;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IFstreamAllocator Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- A std::istream with ability to handle compressed files
|
||||
//- A std::istream with the ability to handle compressed files
|
||||
class IFstreamAllocator
|
||||
{
|
||||
friend class IFstream;
|
||||
protected:
|
||||
|
||||
// Private data
|
||||
// Member Data
|
||||
|
||||
istream* ifPtr_;
|
||||
//- The allocated stream pointer (ifstream or igzstream).
|
||||
std::istream* allocatedPtr_;
|
||||
|
||||
//- The requested compression type
|
||||
IOstream::compressionType compression_;
|
||||
|
||||
|
||||
@ -72,6 +73,13 @@ class IFstreamAllocator
|
||||
|
||||
//- Destructor
|
||||
~IFstreamAllocator();
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Delete the stream pointer
|
||||
void deallocate();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -105,7 +113,7 @@ public:
|
||||
~IFstream();
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
@ -116,16 +124,16 @@ public:
|
||||
// STL stream
|
||||
|
||||
//- Access to underlying std::istream
|
||||
virtual istream& stdStream();
|
||||
virtual std::istream& stdStream();
|
||||
|
||||
//- Const access to underlying std::istream
|
||||
virtual const istream& stdStream() const;
|
||||
virtual const std::istream& stdStream() const;
|
||||
|
||||
|
||||
// Print
|
||||
|
||||
//- Print description of IOstream to Ostream
|
||||
virtual void print(Ostream&) const;
|
||||
virtual void print(Ostream& os) const;
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -43,7 +43,7 @@ Foam::OFstreamAllocator::OFstreamAllocator
|
||||
IOstream::compressionType compression
|
||||
)
|
||||
:
|
||||
ofPtr_(nullptr)
|
||||
allocatedPtr_(nullptr)
|
||||
{
|
||||
if (pathname.empty())
|
||||
{
|
||||
@ -55,30 +55,40 @@ Foam::OFstreamAllocator::OFstreamAllocator
|
||||
|
||||
if (compression == IOstream::COMPRESSED)
|
||||
{
|
||||
// get identically named uncompressed version out of the way
|
||||
// Get identically named uncompressed version out of the way
|
||||
if (isFile(pathname, false))
|
||||
{
|
||||
rm(pathname);
|
||||
}
|
||||
|
||||
ofPtr_ = new ogzstream((pathname + ".gz").c_str());
|
||||
allocatedPtr_ = new ogzstream((pathname + ".gz").c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
// get identically named compressed version out of the way
|
||||
// Get identically named compressed version out of the way
|
||||
if (isFile(pathname + ".gz", false))
|
||||
{
|
||||
rm(pathname + ".gz");
|
||||
}
|
||||
|
||||
ofPtr_ = new ofstream(pathname.c_str());
|
||||
allocatedPtr_ = new std::ofstream(pathname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::OFstreamAllocator::~OFstreamAllocator()
|
||||
{
|
||||
delete ofPtr_;
|
||||
deallocate();
|
||||
}
|
||||
|
||||
|
||||
void Foam::OFstreamAllocator::deallocate()
|
||||
{
|
||||
if (allocatedPtr_)
|
||||
{
|
||||
delete allocatedPtr_;
|
||||
allocatedPtr_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -93,10 +103,10 @@ Foam::OFstream::OFstream
|
||||
)
|
||||
:
|
||||
OFstreamAllocator(pathname, compression),
|
||||
OSstream(*ofPtr_, pathname, format, version, compression)
|
||||
OSstream(*allocatedPtr_, pathname, format, version, compression)
|
||||
{
|
||||
setClosed();
|
||||
setState(ofPtr_->rdstate());
|
||||
setState(allocatedPtr_->rdstate());
|
||||
|
||||
if (!good())
|
||||
{
|
||||
@ -104,8 +114,7 @@ Foam::OFstream::OFstream
|
||||
{
|
||||
InfoInFunction
|
||||
<< "Could not open file " << pathname
|
||||
<< "for input\n"
|
||||
"in stream " << info() << Foam::endl;
|
||||
<< " for output" << nl << info() << Foam::endl;
|
||||
}
|
||||
|
||||
setBad();
|
||||
@ -129,29 +138,29 @@ Foam::OFstream::~OFstream()
|
||||
|
||||
std::ostream& Foam::OFstream::stdStream()
|
||||
{
|
||||
if (!ofPtr_)
|
||||
if (!allocatedPtr_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "No stream allocated." << abort(FatalError);
|
||||
}
|
||||
return *ofPtr_;
|
||||
return *allocatedPtr_;
|
||||
}
|
||||
|
||||
|
||||
const std::ostream& Foam::OFstream::stdStream() const
|
||||
{
|
||||
if (!ofPtr_)
|
||||
if (!allocatedPtr_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "No stream allocated." << abort(FatalError);
|
||||
}
|
||||
return *ofPtr_;
|
||||
return *allocatedPtr_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::OFstream::print(Ostream& os) const
|
||||
{
|
||||
os << " OFstream: ";
|
||||
os << "OFstream: ";
|
||||
OSstream::print(os);
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::OFstream
|
||||
|
||||
Description
|
||||
Output to file stream.
|
||||
Output to file stream, using a OSstream
|
||||
|
||||
SourceFiles
|
||||
OFstream.C
|
||||
@ -47,18 +47,20 @@ using std::ofstream;
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class OFstream;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OFstreamAllocator Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- A std::ostream with ability to handle compressed files
|
||||
//- A std::ostream with the ability to handle compressed files
|
||||
class OFstreamAllocator
|
||||
{
|
||||
friend class OFstream;
|
||||
protected:
|
||||
|
||||
// Member Data
|
||||
|
||||
//- The allocated stream pointer (ofstream or ogzstream).
|
||||
std::ostream* allocatedPtr_;
|
||||
|
||||
ostream* ofPtr_;
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -69,9 +71,16 @@ class OFstreamAllocator
|
||||
IOstream::compressionType compression=IOstream::UNCOMPRESSED
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~OFstreamAllocator();
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Delete the stream pointer
|
||||
void deallocate();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -81,7 +90,7 @@ class OFstreamAllocator
|
||||
|
||||
class OFstream
|
||||
:
|
||||
private OFstreamAllocator,
|
||||
public OFstreamAllocator,
|
||||
public OSstream
|
||||
{
|
||||
public:
|
||||
@ -117,16 +126,16 @@ public:
|
||||
// STL stream
|
||||
|
||||
//- Access to underlying std::ostream
|
||||
virtual ostream& stdStream();
|
||||
virtual std::ostream& stdStream();
|
||||
|
||||
//- Const access to underlying std::ostream
|
||||
virtual const ostream& stdStream() const;
|
||||
virtual const std::ostream& stdStream() const;
|
||||
|
||||
|
||||
// Print
|
||||
|
||||
//- Print description of IOstream to Ostream
|
||||
void print(Ostream&) const;
|
||||
void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -799,7 +799,8 @@ Foam::Istream& Foam::ISstream::read(char* buf, std::streamsize count)
|
||||
|
||||
Foam::Istream& Foam::ISstream::rewind()
|
||||
{
|
||||
stdStream().rdbuf()->pubseekpos(0);
|
||||
// pubseekpos() rather than seekg() so that it works with gzstream
|
||||
stdStream().rdbuf()->pubseekpos(0, std::ios_base::in);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -56,23 +56,23 @@ class ISstream
|
||||
// Private data
|
||||
|
||||
fileName name_;
|
||||
istream& is_;
|
||||
std::istream& is_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
char nextValid();
|
||||
|
||||
void readWordToken(token&);
|
||||
void readWordToken(token& t);
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
|
||||
//- Read a verbatim string (excluding block delimiters).
|
||||
Istream& readVerbatim(string&);
|
||||
Istream& readVerbatim(string& str);
|
||||
|
||||
//- Read a variable name (includes '{')
|
||||
Istream& readVariable(string&);
|
||||
Istream& readVariable(string& str);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ISstream&) = delete;
|
||||
@ -85,7 +85,7 @@ public:
|
||||
//- Construct as wrapper around istream
|
||||
inline ISstream
|
||||
(
|
||||
istream& is,
|
||||
std::istream& is,
|
||||
const string& name,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion,
|
||||
@ -123,7 +123,7 @@ public:
|
||||
// Read functions
|
||||
|
||||
//- Raw, low-level get character function.
|
||||
inline ISstream& get(char&);
|
||||
inline ISstream& get(char& c);
|
||||
|
||||
//- Raw, low-level peek function.
|
||||
// Does not remove the character from the stream.
|
||||
@ -132,36 +132,36 @@ public:
|
||||
inline int peek();
|
||||
|
||||
//- Raw, low-level getline into a string function.
|
||||
inline ISstream& getLine(string&);
|
||||
inline ISstream& getLine(string& str);
|
||||
|
||||
//- Raw, low-level putback character function.
|
||||
inline ISstream& putback(const char&);
|
||||
inline ISstream& putback(const char c);
|
||||
|
||||
//- Return next token from stream
|
||||
virtual Istream& read(token&);
|
||||
virtual Istream& read(token& t);
|
||||
|
||||
//- Read a character
|
||||
virtual Istream& read(char&);
|
||||
virtual Istream& read(char& c);
|
||||
|
||||
//- Read a word
|
||||
virtual Istream& read(word&);
|
||||
virtual Istream& read(word& str);
|
||||
|
||||
//- Read a string (including enclosing double-quotes).
|
||||
// Backslashes are retained, except when escaping double-quotes
|
||||
// and an embedded newline character.
|
||||
virtual Istream& read(string&);
|
||||
virtual Istream& read(string& str);
|
||||
|
||||
//- Read a label
|
||||
virtual Istream& read(label&);
|
||||
virtual Istream& read(label& val);
|
||||
|
||||
//- Read a floatScalar
|
||||
virtual Istream& read(floatScalar&);
|
||||
virtual Istream& read(floatScalar& val);
|
||||
|
||||
//- Read a doubleScalar
|
||||
virtual Istream& read(doubleScalar&);
|
||||
virtual Istream& read(doubleScalar& val);
|
||||
|
||||
//- Read binary block
|
||||
virtual Istream& read(char*, std::streamsize);
|
||||
virtual Istream& read(char* buf, std::streamsize count);
|
||||
|
||||
//- Rewind and return the stream so that it may be read again
|
||||
virtual Istream& rewind();
|
||||
@ -169,20 +169,20 @@ public:
|
||||
|
||||
// Stream state functions
|
||||
|
||||
//- Set flags of output stream
|
||||
//- Set stream flags
|
||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags flags);
|
||||
|
||||
|
||||
// STL stream
|
||||
|
||||
//- Access to underlying std::istream
|
||||
virtual istream& stdStream()
|
||||
virtual std::istream& stdStream()
|
||||
{
|
||||
return is_;
|
||||
}
|
||||
|
||||
//- Const access to underlying std::istream
|
||||
virtual const istream& stdStream() const
|
||||
virtual const std::istream& stdStream() const
|
||||
{
|
||||
return is_;
|
||||
}
|
||||
@ -191,7 +191,7 @@ public:
|
||||
// Print
|
||||
|
||||
//- Print description of IOstream to Ostream
|
||||
virtual void print(Ostream&) const;
|
||||
virtual void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -23,13 +23,11 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ISstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::ISstream::ISstream
|
||||
(
|
||||
istream& is,
|
||||
std::istream& is,
|
||||
const string& name,
|
||||
streamFormat format,
|
||||
versionNumber version,
|
||||
@ -74,9 +72,9 @@ inline int Foam::ISstream::peek()
|
||||
}
|
||||
|
||||
|
||||
inline Foam::ISstream& Foam::ISstream::getLine(string& s)
|
||||
inline Foam::ISstream& Foam::ISstream::getLine(string& str)
|
||||
{
|
||||
getline(is_, s);
|
||||
std::getline(is_, str);
|
||||
setState(is_.rdstate());
|
||||
lineNumber_++;
|
||||
|
||||
@ -84,7 +82,7 @@ inline Foam::ISstream& Foam::ISstream::getLine(string& s)
|
||||
}
|
||||
|
||||
|
||||
inline Foam::ISstream& Foam::ISstream::putback(const char& c)
|
||||
inline Foam::ISstream& Foam::ISstream::putback(const char c)
|
||||
{
|
||||
if (c == '\n')
|
||||
{
|
||||
|
||||
@ -56,7 +56,7 @@ class OSstream
|
||||
// Private data
|
||||
|
||||
fileName name_;
|
||||
ostream& os_;
|
||||
std::ostream& os_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
@ -72,7 +72,7 @@ public:
|
||||
//- Construct and set stream status
|
||||
OSstream
|
||||
(
|
||||
ostream& os,
|
||||
std::ostream& os,
|
||||
const string& name,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion,
|
||||
@ -105,45 +105,45 @@ public:
|
||||
// Write functions
|
||||
|
||||
//- Write next token to stream
|
||||
virtual Ostream& write(const token&);
|
||||
virtual Ostream& write(const token& t);
|
||||
|
||||
//- Write character
|
||||
virtual Ostream& write(const char);
|
||||
virtual Ostream& write(const char c);
|
||||
|
||||
//- Write character string
|
||||
virtual Ostream& write(const char*);
|
||||
virtual Ostream& write(const char* str);
|
||||
|
||||
//- Write word
|
||||
virtual Ostream& write(const word&);
|
||||
virtual Ostream& write(const word& str);
|
||||
|
||||
//- Write string
|
||||
// In the rare case that the string contains a final trailing
|
||||
// backslash, it will be dropped to the appearance of an escaped
|
||||
// double-quote.
|
||||
virtual Ostream& write(const string&);
|
||||
virtual Ostream& write(const string& str);
|
||||
|
||||
//- Write std::string surrounded by quotes.
|
||||
// Optional write without quotes.
|
||||
virtual Ostream& writeQuoted
|
||||
(
|
||||
const std::string&,
|
||||
const std::string& str,
|
||||
const bool quoted=true
|
||||
);
|
||||
|
||||
//- Write int32_t
|
||||
virtual Ostream& write(const int32_t);
|
||||
virtual Ostream& write(const int32_t val);
|
||||
|
||||
//- Write int64_t
|
||||
virtual Ostream& write(const int64_t);
|
||||
virtual Ostream& write(const int64_t val);
|
||||
|
||||
//- Write floatScalar
|
||||
virtual Ostream& write(const floatScalar);
|
||||
virtual Ostream& write(const floatScalar val);
|
||||
|
||||
//- Write doubleScalar
|
||||
virtual Ostream& write(const doubleScalar);
|
||||
virtual Ostream& write(const doubleScalar val);
|
||||
|
||||
//- Write binary block
|
||||
virtual Ostream& write(const char*, std::streamsize);
|
||||
virtual Ostream& write(const char* buf, std::streamsize count);
|
||||
|
||||
//- Add indentation characters
|
||||
virtual void indent();
|
||||
@ -151,8 +151,8 @@ public:
|
||||
|
||||
// Stream state functions
|
||||
|
||||
//- Set flags of output stream
|
||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags flags);
|
||||
//- Set stream flags
|
||||
virtual ios_base::fmtflags flags(const ios_base::fmtflags f);
|
||||
|
||||
//- Flush stream
|
||||
virtual void flush();
|
||||
@ -163,26 +163,28 @@ public:
|
||||
//- Get width of output field
|
||||
virtual int width() const;
|
||||
|
||||
//- Set width of output field (and return old width)
|
||||
virtual int width(const int);
|
||||
//- Set width of output field
|
||||
// \return previous width
|
||||
virtual int width(const int w);
|
||||
|
||||
//- Get precision of output field
|
||||
virtual int precision() const;
|
||||
|
||||
//- Set precision of output field (and return old precision)
|
||||
virtual int precision(const int);
|
||||
//- Set precision of output field
|
||||
// \return old precision
|
||||
virtual int precision(const int p);
|
||||
|
||||
|
||||
// STL stream
|
||||
|
||||
//- Access to underlying std::ostream
|
||||
virtual ostream& stdStream()
|
||||
virtual std::ostream& stdStream()
|
||||
{
|
||||
return os_;
|
||||
}
|
||||
|
||||
//- Const access to underlying std::ostream
|
||||
virtual const ostream& stdStream() const
|
||||
virtual const std::ostream& stdStream() const
|
||||
{
|
||||
return os_;
|
||||
}
|
||||
@ -191,7 +193,7 @@ public:
|
||||
// Print
|
||||
|
||||
//- Print description of IOstream to Ostream
|
||||
virtual void print(Ostream&) const;
|
||||
virtual void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ License
|
||||
|
||||
inline Foam::OSstream::OSstream
|
||||
(
|
||||
ostream& os,
|
||||
std::ostream& os,
|
||||
const string& name,
|
||||
streamFormat format,
|
||||
versionNumber version,
|
||||
|
||||
@ -43,7 +43,7 @@ inline void Foam::prefixOSstream::checkWritePrefix()
|
||||
|
||||
Foam::prefixOSstream::prefixOSstream
|
||||
(
|
||||
ostream& os,
|
||||
std::ostream& os,
|
||||
const string& name,
|
||||
streamFormat format,
|
||||
versionNumber version,
|
||||
@ -182,4 +182,5 @@ void Foam::prefixOSstream::indent()
|
||||
OSstream::indent();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -71,7 +71,7 @@ public:
|
||||
//- Construct and set stream status
|
||||
prefixOSstream
|
||||
(
|
||||
ostream& os,
|
||||
std::ostream& os,
|
||||
const string& name,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion,
|
||||
@ -83,13 +83,13 @@ public:
|
||||
|
||||
// Enquiry
|
||||
|
||||
//- Return the prefix of the stream
|
||||
//- Return the sream prefix
|
||||
const string& prefix() const
|
||||
{
|
||||
return prefix_;
|
||||
}
|
||||
|
||||
//- Return non-const access to the prefix of the stream
|
||||
//- Return non-const access to the stream prefix
|
||||
string& prefix()
|
||||
{
|
||||
return prefix_;
|
||||
@ -99,42 +99,42 @@ public:
|
||||
// Write functions
|
||||
|
||||
//- Write next token to stream
|
||||
virtual Ostream& write(const token&);
|
||||
virtual Ostream& write(const token& t);
|
||||
|
||||
//- Write character
|
||||
virtual Ostream& write(const char);
|
||||
virtual Ostream& write(const char c);
|
||||
|
||||
//- Write character string
|
||||
virtual Ostream& write(const char*);
|
||||
virtual Ostream& write(const char* str);
|
||||
|
||||
//- Write word
|
||||
virtual Ostream& write(const word&);
|
||||
virtual Ostream& write(const word& val);
|
||||
|
||||
//- Write string
|
||||
virtual Ostream& write(const string&);
|
||||
virtual Ostream& write(const string& val);
|
||||
|
||||
//- Write std::string surrounded by quotes.
|
||||
// Optional write without quotes.
|
||||
virtual Ostream& writeQuoted
|
||||
(
|
||||
const std::string&,
|
||||
const std::string& val,
|
||||
const bool quoted=true
|
||||
);
|
||||
|
||||
//- Write int32_t
|
||||
virtual Ostream& write(const int32_t);
|
||||
virtual Ostream& write(const int32_t val);
|
||||
|
||||
//- Write int64_t
|
||||
virtual Ostream& write(const int64_t);
|
||||
virtual Ostream& write(const int64_t val);
|
||||
|
||||
//- Write floatScalar
|
||||
virtual Ostream& write(const floatScalar);
|
||||
virtual Ostream& write(const floatScalar val);
|
||||
|
||||
//- Write doubleScalar
|
||||
virtual Ostream& write(const doubleScalar);
|
||||
virtual Ostream& write(const doubleScalar val);
|
||||
|
||||
//- Write binary block
|
||||
virtual Ostream& write(const char*, std::streamsize);
|
||||
virtual Ostream& write(const char* buf, std::streamsize count);
|
||||
|
||||
//- Add indentation characters
|
||||
virtual void indent();
|
||||
@ -143,7 +143,7 @@ public:
|
||||
// Print
|
||||
|
||||
//- Print description of IOstream to Ostream
|
||||
virtual void print(Ostream&) const;
|
||||
virtual void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,141 +1,13 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::IStringStream
|
||||
|
||||
Description
|
||||
Input from memory buffer stream.
|
||||
|
||||
SourceFiles
|
||||
StringStreamsPrint.C
|
||||
Compatibility include
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IStringStream_H
|
||||
#define IStringStream_H
|
||||
|
||||
#include "ISstream.H"
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IStringStream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class IStringStream
|
||||
:
|
||||
public ISstream
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from string
|
||||
IStringStream
|
||||
(
|
||||
const string& buffer,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
)
|
||||
:
|
||||
ISstream
|
||||
(
|
||||
*(new std::istringstream(buffer)),
|
||||
"input",
|
||||
format,
|
||||
version
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
//- Construct from char*
|
||||
IStringStream
|
||||
(
|
||||
const char* buffer,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
)
|
||||
:
|
||||
ISstream
|
||||
(
|
||||
*(new std::istringstream(buffer)),
|
||||
"input",
|
||||
format,
|
||||
version
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
~IStringStream()
|
||||
{
|
||||
delete &dynamic_cast<std::istringstream&>(stdStream());
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the string
|
||||
string str() const
|
||||
{
|
||||
return dynamic_cast<const std::istringstream&>
|
||||
(
|
||||
stdStream()
|
||||
).str();
|
||||
}
|
||||
|
||||
|
||||
// Print
|
||||
|
||||
//- Print description to Ostream
|
||||
void print(Ostream&) const;
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Return a non-const reference to const Istream
|
||||
// Needed for read-constructors where the stream argument is temporary:
|
||||
// e.g. thing thisThing(IFstream("thingFileName")());
|
||||
Istream& operator()() const
|
||||
{
|
||||
return const_cast<IStringStream&>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
#include "StringStream.H"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -1,140 +1,13 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::OStringStream
|
||||
|
||||
Description
|
||||
Output to memory buffer stream.
|
||||
|
||||
SourceFiles
|
||||
StringStreamsPrint.C
|
||||
Compatibility include
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef OStringStream_H
|
||||
#define OStringStream_H
|
||||
|
||||
#include "OSstream.H"
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OStringStream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class OStringStream
|
||||
:
|
||||
public OSstream
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct and set stream status
|
||||
OStringStream
|
||||
(
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
)
|
||||
:
|
||||
OSstream
|
||||
(
|
||||
*(new std::ostringstream()),
|
||||
"output",
|
||||
format,
|
||||
version
|
||||
)
|
||||
{}
|
||||
|
||||
//- Construct as copy
|
||||
OStringStream(const OStringStream& oss)
|
||||
:
|
||||
OSstream
|
||||
(
|
||||
*(
|
||||
new std::ostringstream
|
||||
(
|
||||
dynamic_cast<const std::ostringstream&>
|
||||
(
|
||||
oss.stdStream()
|
||||
).str()
|
||||
)
|
||||
),
|
||||
oss.name(),
|
||||
oss.format(),
|
||||
oss.version()
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
~OStringStream()
|
||||
{
|
||||
delete &dynamic_cast<std::ostringstream&>(stdStream());
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the string
|
||||
string str() const
|
||||
{
|
||||
return dynamic_cast<const std::ostringstream&>
|
||||
(
|
||||
stdStream()
|
||||
).str();
|
||||
}
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Rewind the OStringStream
|
||||
void rewind()
|
||||
{
|
||||
stdStream().rdbuf()->pubseekpos(0);
|
||||
}
|
||||
|
||||
|
||||
// Print
|
||||
|
||||
//- Print description to Ostream
|
||||
void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
#include "StringStream.H"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -21,15 +21,11 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Prints out a description of the StringStream
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IStringStream.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::IStringStream::print(Ostream& os) const
|
||||
{
|
||||
@ -40,6 +36,8 @@ void Foam::IStringStream::print(Ostream& os) const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::OStringStream::print(Ostream& os) const
|
||||
{
|
||||
os << "OStringStream " << name() << " : "
|
||||
247
src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H
Normal file
247
src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H
Normal file
@ -0,0 +1,247 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
InClass
|
||||
Foam::StringStream
|
||||
|
||||
Description
|
||||
Input/output from string buffers.
|
||||
|
||||
SourceFiles
|
||||
StringStream.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef StringStream_H
|
||||
#define StringStream_H
|
||||
|
||||
#include "ISstream.H"
|
||||
#include "OSstream.H"
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class StringStreamAllocator Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Allocator for variants of a std stringstream
|
||||
template<class StreamType>
|
||||
class StringStreamAllocator
|
||||
{
|
||||
protected:
|
||||
|
||||
// Member Data
|
||||
|
||||
//- The allocated stream pointer.
|
||||
StreamType* allocatedPtr_;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
StringStreamAllocator()
|
||||
:
|
||||
allocatedPtr_(new StreamType())
|
||||
{}
|
||||
|
||||
//- Construct from pointer, taking ownership
|
||||
StringStreamAllocator(StreamType* ptr)
|
||||
:
|
||||
allocatedPtr_(ptr)
|
||||
{}
|
||||
|
||||
//- Construct from string
|
||||
StringStreamAllocator(const std::string& buffer)
|
||||
:
|
||||
allocatedPtr_(new StreamType(buffer))
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
~StringStreamAllocator()
|
||||
{
|
||||
deallocate();
|
||||
}
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Delete the stream pointer
|
||||
void deallocate()
|
||||
{
|
||||
if (allocatedPtr_)
|
||||
{
|
||||
delete allocatedPtr_;
|
||||
allocatedPtr_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Public Member Functions
|
||||
|
||||
//- Get the string
|
||||
Foam::string str() const
|
||||
{
|
||||
return allocatedPtr_->str();
|
||||
}
|
||||
|
||||
//- Set the string
|
||||
void str(const std::string& s)
|
||||
{
|
||||
allocatedPtr_->str(s);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IStringStream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Input from string buffer, using a ISstream
|
||||
class IStringStream
|
||||
:
|
||||
public StringStreamAllocator<std::istringstream>,
|
||||
public ISstream
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from string
|
||||
IStringStream
|
||||
(
|
||||
const Foam::string& buffer,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
)
|
||||
:
|
||||
StringStreamAllocator<std::istringstream>(buffer),
|
||||
ISstream(*allocatedPtr_, "input", format, version)
|
||||
{}
|
||||
|
||||
|
||||
//- Construct from char*
|
||||
IStringStream
|
||||
(
|
||||
const char* buffer,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
)
|
||||
:
|
||||
StringStreamAllocator<std::istringstream>(buffer),
|
||||
ISstream(*allocatedPtr_, "input", format, version)
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
~IStringStream()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Print description to Ostream
|
||||
void print(Ostream& os) const;
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Return a non-const reference to const Istream
|
||||
// Needed for read-constructors where the stream argument is temporary:
|
||||
// e.g. thing thisThing(IFstream("thingFileName")());
|
||||
Istream& operator()() const
|
||||
{
|
||||
return const_cast<IStringStream&>(*this);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OStringStream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Output to string buffer, using a OSstream
|
||||
class OStringStream
|
||||
:
|
||||
public StringStreamAllocator<std::ostringstream>,
|
||||
public OSstream
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct and set stream status
|
||||
OStringStream
|
||||
(
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
)
|
||||
:
|
||||
StringStreamAllocator<std::ostringstream>(),
|
||||
OSstream(*allocatedPtr_, "output", format, version)
|
||||
{}
|
||||
|
||||
//- Construct as copy
|
||||
OStringStream(const OStringStream& oss)
|
||||
:
|
||||
StringStreamAllocator<std::ostringstream>(oss.str()),
|
||||
OSstream(*allocatedPtr_, oss.name(), oss.format(), oss.version())
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
~OStringStream()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Rewind the output stream
|
||||
void rewind()
|
||||
{
|
||||
// pubseekpos() instead of seekp() for symmetry with other classes
|
||||
allocatedPtr_->rdbuf()->pubseekpos(0, std::ios_base::out);
|
||||
}
|
||||
|
||||
//- Print description to Ostream
|
||||
void print(Ostream& os) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -126,6 +126,61 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OSHA1streamAllocator Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Allocator for an osha1stream
|
||||
class OSHA1streamAllocator
|
||||
{
|
||||
protected:
|
||||
|
||||
// Member data
|
||||
|
||||
//- The allocated stream pointer
|
||||
osha1stream* allocatedPtr_;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
OSHA1streamAllocator()
|
||||
:
|
||||
allocatedPtr_(new osha1stream())
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
~OSHA1streamAllocator()
|
||||
{
|
||||
deallocate();
|
||||
}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Delete the stream pointer
|
||||
void deallocate()
|
||||
{
|
||||
if (allocatedPtr_)
|
||||
{
|
||||
delete allocatedPtr_;
|
||||
allocatedPtr_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Full access to the sha1
|
||||
SHA1& sha1()
|
||||
{
|
||||
return allocatedPtr_->sha1();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OSHA1stream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -133,6 +188,7 @@ public:
|
||||
//- The output stream for calculating SHA1 digests
|
||||
class OSHA1stream
|
||||
:
|
||||
public OSHA1streamAllocator,
|
||||
public OSstream
|
||||
{
|
||||
|
||||
@ -155,33 +211,20 @@ public:
|
||||
versionNumber version=currentVersion
|
||||
)
|
||||
:
|
||||
OSstream
|
||||
(
|
||||
*(new osha1stream),
|
||||
"OSHA1stream",
|
||||
format,
|
||||
version
|
||||
)
|
||||
OSHA1streamAllocator(),
|
||||
OSstream(*allocatedPtr_, "OSHA1stream", format, version)
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
~OSHA1stream()
|
||||
{
|
||||
delete &dynamic_cast<osha1stream&>(stdStream());
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Full access to the sha1
|
||||
Foam::SHA1& sha1()
|
||||
{
|
||||
return dynamic_cast<osha1stream&>(stdStream()).sha1();
|
||||
}
|
||||
|
||||
//- Return SHA1::Digest for the data processed until now
|
||||
Foam::SHA1Digest digest()
|
||||
{
|
||||
|
||||
@ -59,8 +59,8 @@ namespace Foam
|
||||
|
||||
class token;
|
||||
|
||||
Istream& operator>>(Istream&, token&);
|
||||
Ostream& operator<<(Ostream&, const token&);
|
||||
Istream& operator>>(Istream& is, token& t);
|
||||
Ostream& operator<<(Ostream& os, const token& t);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -418,8 +418,8 @@ public:
|
||||
|
||||
// IOstream operators
|
||||
|
||||
friend Istream& operator>>(Istream&, token&);
|
||||
friend Ostream& operator<<(Ostream&, const token&);
|
||||
friend Istream& operator>>(Istream& is, token& t);
|
||||
friend Ostream& operator<<(Ostream& os, const token& t);
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const punctuationToken&);
|
||||
friend ostream& operator<<(ostream&, const punctuationToken&);
|
||||
|
||||
@ -23,8 +23,6 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::token::clear()
|
||||
|
||||
@ -39,7 +39,7 @@ Foam::token::token(Istream& is)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * IOstream operators * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, token& t)
|
||||
{
|
||||
|
||||
@ -30,7 +30,7 @@ Description
|
||||
|
||||
#include "Time.H"
|
||||
#include "OSspecific.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ License
|
||||
#include "ListOps.H"
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ License
|
||||
|
||||
#include "entry.H"
|
||||
#include "dictionary.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -25,8 +25,7 @@ License
|
||||
|
||||
#include "codeStream.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
#include "IStringStream.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "dynamicCode.H"
|
||||
#include "dynamicCodeContext.H"
|
||||
#include "Time.H"
|
||||
|
||||
@ -26,8 +26,7 @@ License
|
||||
#include "removeEntry.H"
|
||||
#include "dictionary.H"
|
||||
#include "stringListOps.H"
|
||||
#include "IStringStream.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -25,8 +25,7 @@ License
|
||||
|
||||
#include "primitiveEntry.H"
|
||||
#include "dictionary.H"
|
||||
#include "IStringStream.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "fileName.H"
|
||||
#include "dictionary.H"
|
||||
#include "JobInfo.H"
|
||||
|
||||
@ -24,7 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "fileName.H"
|
||||
#include "dictionary.H"
|
||||
#include "JobInfo.H"
|
||||
|
||||
@ -31,17 +31,18 @@ License
|
||||
|
||||
int Foam::messageStream::level(Foam::debug::debugSwitch("level", 2));
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::messageStream::messageStream
|
||||
(
|
||||
const string& title,
|
||||
errorSeverity sev,
|
||||
const errorSeverity severity,
|
||||
const int maxErrors
|
||||
)
|
||||
:
|
||||
title_(title),
|
||||
severity_(sev),
|
||||
severity_(severity),
|
||||
maxErrors_(maxErrors),
|
||||
errorCount_(0)
|
||||
{}
|
||||
@ -56,6 +57,8 @@ Foam::messageStream::messageStream(const dictionary& dict)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::OSstream& Foam::messageStream::masterStream(const label communicator)
|
||||
{
|
||||
if (UPstream::warnComm != -1 && communicator != UPstream::warnComm)
|
||||
@ -76,6 +79,8 @@ Foam::OSstream& Foam::messageStream::masterStream(const label communicator)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::OSstream& Foam::messageStream::operator()
|
||||
(
|
||||
const char* functionName,
|
||||
@ -237,7 +242,7 @@ Foam::messageStream::operator Foam::OSstream&()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Global Variables * * * * * * * * * * * * * //
|
||||
|
||||
Foam::messageStream Foam::SeriousError
|
||||
(
|
||||
|
||||
@ -28,8 +28,8 @@ Description
|
||||
Class to handle messaging in a simple, consistent stream-based
|
||||
manner.
|
||||
|
||||
The messageStream class is globaly instantiated with a title string a
|
||||
given severity, which controls the program termination, and a number of
|
||||
The messageStream class is globaly instantiated with a title string and
|
||||
a severity (which controls the program termination) and a number of
|
||||
errors before termination. Errors, messages and other data are piped to
|
||||
the messageStream class in the standard manner.
|
||||
|
||||
@ -104,13 +104,13 @@ public:
|
||||
messageStream
|
||||
(
|
||||
const string& title,
|
||||
errorSeverity,
|
||||
const errorSeverity severity,
|
||||
const int maxErrors = 0
|
||||
);
|
||||
|
||||
|
||||
//- Construct from dictionary
|
||||
messageStream(const dictionary&);
|
||||
//- Construct as Fatal from dictionary, extracting the 'title'.
|
||||
messageStream(const dictionary& dict);
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
@ -25,7 +25,7 @@ License
|
||||
|
||||
#include "dimensionSet.H"
|
||||
#include "dimensionedScalar.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ SourceFiles
|
||||
#include "word.H"
|
||||
#include "fileName.H"
|
||||
#include "parRun.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -28,7 +28,7 @@ License
|
||||
#include "boolList.H"
|
||||
#include "IOstreams.H"
|
||||
#include "IOmanip.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "Pstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -25,7 +25,7 @@ License
|
||||
|
||||
#include "vectorTensorTransform.H"
|
||||
#include "IOstreams.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -28,7 +28,6 @@ License
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <sstream>
|
||||
#include <cerrno>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -28,7 +28,6 @@ License
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <sstream>
|
||||
#include <cerrno>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -27,8 +27,6 @@ License
|
||||
#include "stringOps.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::name(const char* fmt, const uint32_t val)
|
||||
|
||||
@ -27,8 +27,6 @@ License
|
||||
#include "stringOps.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::name(const char* fmt, const uint64_t val)
|
||||
|
||||
@ -25,7 +25,7 @@ License
|
||||
|
||||
#include "quaternion.H"
|
||||
#include "IOstreams.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ License
|
||||
|
||||
#include "septernion.H"
|
||||
#include "IOstreams.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ License
|
||||
#include "typeInfo.H"
|
||||
#include "OSspecific.H"
|
||||
#include "etcFiles.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
#include "ccmWriter.H"
|
||||
#include "dictionary.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "ccmInternal.H" // include last to avoid any strange interactions
|
||||
|
||||
@ -45,7 +45,7 @@ void Foam::vtk::writeSurfFields
|
||||
|
||||
const bool legacy_(opts.legacy());
|
||||
|
||||
std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
|
||||
std::ofstream os(baseName + (legacy_ ? ".vtk" : ".vtp"));
|
||||
autoPtr<vtk::formatter> format = opts.newFormatter(os);
|
||||
|
||||
// Same payload size for points and vector fields!
|
||||
|
||||
@ -24,7 +24,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ensightReadFile.H"
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "NASCore.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ License
|
||||
#include "ListOps.H"
|
||||
#include "clock.H"
|
||||
#include "PackedBoolList.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
|
||||
|
||||
@ -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())
|
||||
{
|
||||
|
||||
@ -33,7 +33,7 @@ License
|
||||
#include "mixedFvPatchFields.H"
|
||||
#include "fixedGradientFvPatchFields.H"
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "globalIndex.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -25,7 +25,7 @@ License
|
||||
|
||||
#include "NASedgeFormat.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "PackedBoolList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
#include "OBJedgeFormat.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
@ -27,7 +27,7 @@ License
|
||||
#include "ListOps.H"
|
||||
#include "clock.H"
|
||||
#include "PackedBoolList.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ void Foam::vtk::writeCellSetFaces
|
||||
|
||||
const bool legacy_(opts.legacy());
|
||||
|
||||
std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
|
||||
std::ofstream os(baseName + (legacy_ ? ".vtk" : ".vtp"));
|
||||
|
||||
autoPtr<vtk::formatter> format = opts.newFormatter(os);
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ void Foam::vtk::writeFaceSet
|
||||
|
||||
const bool legacy_(opts.legacy());
|
||||
|
||||
std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
|
||||
std::ofstream os(baseName + (legacy_ ? ".vtk" : ".vtp"));
|
||||
|
||||
autoPtr<vtk::formatter> format = opts.newFormatter(os);
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ void Foam::vtk::writePointSet
|
||||
|
||||
const bool legacy_(opts.legacy());
|
||||
|
||||
std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
|
||||
std::ofstream os(baseName + (legacy_ ? ".vtk" : ".vtp"));
|
||||
|
||||
autoPtr<vtk::formatter> format = opts.newFormatter(os);
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ SourceFiles
|
||||
|
||||
#include "surfaceReader.H"
|
||||
#include "ensightReadFile.H"
|
||||
#include "StringStream.H"
|
||||
#include "Tuple2.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -30,7 +30,7 @@ License
|
||||
#include "ensightPartFaces.H"
|
||||
#include "ensightSerialOutput.H"
|
||||
#include "ensightPTraits.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "AC3DsurfaceFormat.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "PrimitivePatch.H"
|
||||
#include "faceTraits.H"
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
#include "AC3DsurfaceFormatCore.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "AC3DsurfaceFormatCore.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ License
|
||||
#include "surfaceFormatsCore.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "OFstream.H"
|
||||
#include "faceTraits.H"
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ License
|
||||
|
||||
#include "NASsurfaceFormat.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "faceTraits.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
#include "OBJsurfaceFormat.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "OFstream.H"
|
||||
#include "ListOps.H"
|
||||
#include "faceTraits.H"
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
#include "OFFsurfaceFormat.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "faceTraits.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user