Merge branch 'feature-streams-cleanup' into 'develop'

Feature streams cleanup

See merge request !127
This commit is contained in:
Andrew Heather
2017-07-18 12:48:31 +01:00
113 changed files with 824 additions and 647 deletions

View File

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

View File

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

View File

@ -25,7 +25,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "IStringStream.H"
#include "StringStream.H"
#include "wordList.H"
#include "IOstreams.H"

View File

@ -37,7 +37,7 @@ See also
#include "wordReList.H"
#include "IOstreams.H"
#include "IStringStream.H"
#include "StringStream.H"
#include "scalar.H"
#include "vector.H"

View File

@ -25,8 +25,8 @@ Description
\*---------------------------------------------------------------------------*/
#include "OStringStream.H"
#include "IOstreams.H"
#include "StringStream.H"
using namespace Foam;
@ -35,15 +35,28 @@ 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();
os << "%%%% reset";
Info<< "after reset:" << nl
<< os.str() << endl;
Info<< "End\n" << endl;

View File

@ -30,7 +30,7 @@ Description
#include "uLabel.H"
#include "IOstreams.H"
#include "PackedBoolList.H"
#include "IStringStream.H"
#include "StringStream.H"
using namespace Foam;

View File

@ -29,7 +29,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "IStringStream.H"
#include "StringStream.H"
#include "Polynomial.H"
#include "polynomialFunction.H"
#include "Random.H"

View File

@ -25,8 +25,7 @@ License
#include "StaticHashTable.H"
#include "IOstreams.H"
#include "IStringStream.H"
#include "OStringStream.H"
#include "StringStream.H"
using namespace Foam;

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

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

View File

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

View File

@ -34,8 +34,6 @@ Description
#include "Time.H"
#include "polyMesh.H"
#include "IOstreams.H"
#include "OStringStream.H"
#include "IStringStream.H"
using namespace Foam;

View File

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

View File

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

View File

@ -30,7 +30,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "OSHA1stream.H"
#include "IStringStream.H"
#include "StringStream.H"
#include "dictionary.H"
using namespace Foam;
@ -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;
}

View File

@ -32,7 +32,6 @@ Description
#include "dictionary.H"
#include "nil.H"
#include "IOstreams.H"
#include "IStringStream.H"
namespace Foam
{

View File

@ -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+.*\" )")());

View File

@ -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;
@ -41,22 +41,28 @@ using namespace Foam;
int main(int argc, char *argv[])
{
argList::noBanner();
argList::noParallel();
argList::validArgs.insert("string .. stringN");
argList::addOption("file", "name");
argList::addOption("repeat", "count");
argList::addBoolOption("verbose", "report for each repeat");
argList args(argc, argv, false, true);
const label repeat = args.optionLookupOrDefault<label>("repeat", 1);
const bool optVerbose = args.optionFound("verbose");
cpuTime timer;
for (label count = 0; count < repeat; ++count)
{
const bool verbose = (optVerbose || count == 0);
for (label argI=1; argI < args.size(); ++argI)
{
const string& rawArg = args[argI];
if (count == 0)
if (verbose)
{
Info<< "input string: " << rawArg << nl;
}
@ -71,14 +77,15 @@ int main(int argc, char *argv[])
// is.putback(ch);
int lookahead = is.peek();
if (count == 0)
if (verbose)
{
Info<< "token: " << tok.info();
Info<< " lookahead: '" << char(lookahead) << "'" << endl;
Info<< "token: " << tok.info()
<< " lookahead: '" << char(lookahead) << "'"
<< endl;
}
}
if (count == 0)
if (verbose)
{
Info<< nl;
IOobject::writeDivider(Info);
@ -89,31 +96,44 @@ int main(int argc, char *argv[])
Info<< "tokenized args " << repeat << " times in "
<< timer.cpuTimeIncrement() << " s\n\n";
if (args.optionFound("file"))
fileName inputFile;
if (args.optionReadIfPresent("file", inputFile))
{
IFstream is(inputFile);
for (label count = 0; count < repeat; ++count)
{
IFstream is(args["file"]);
const bool verbose = (optVerbose || count == 0);
label nTokens = 0;
if (count == 0)
if (count)
{
Info<< "tokenizing file: " << args["file"] << nl;
is.rewind();
}
Info<< nl
<< "tokenizing file (pass #" << (count+1) << ") "
<< inputFile << nl
<< "state: " << is.info() << endl;
while (is.good())
{
token tok(is);
if (count == 0)
if (verbose)
{
Info<< "token: " << tok.info() << endl;
}
++nTokens;
}
if (count == 0)
if (verbose)
{
Info<< nl;
IOobject::writeDivider(Info);
}
Info<<"pass #" << (count+1)
<< " extracted " << nTokens << " tokens" << endl;
}
Info<< "tokenized file " << repeat << " times in "

View File

@ -30,7 +30,6 @@ Description
#include "OSspecific.H"
#include "IOstreams.H"
#include "IStringStream.H"
#include "labelList.H"
#include "DynamicList.H"
#include "face.H"

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;

View File

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

View File

@ -26,7 +26,7 @@ License
#include "boundaryTemplates.H"
#include "Time.H"
#include "IFstream.H"
#include "OStringStream.H"
#include "StringStream.H"
using namespace Foam;

View File

@ -71,8 +71,7 @@ Note
#include "ModifiableMeshedSurface.H"
#include "UnsortedMeshedSurfaces.H"
#include "IStringStream.H"
#include "OStringStream.H"
#include "StringStream.H"
using namespace Foam;

View File

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