From 0ca0a6264b1b44cd337752bb0c0cef1c50105c01 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 13 Nov 2017 11:23:17 +0100 Subject: [PATCH] STYLE: use readLabel/readScalar (string) instead of via IStringStream --- .../conversion/ideasUnvToFoam/ideasUnvToFoam.C | 16 +++++++++------- .../ensight/ensightSurfaceWriterTemplates.C | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C index 7e09194c37..398351e3f8 100644 --- a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C +++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C @@ -68,9 +68,11 @@ namespace Foam return Hash::operator()(t, 0); } } + const string SEPARATOR(" -1"); -bool isSeparator(const string& line) + +bool isSeparator(const std::string& line) { return line.substr(0, 6) == SEPARATOR; } @@ -100,7 +102,7 @@ label readTag(IFstream& is) } while (tag == SEPARATOR); - return readLabel(IStringStream(tag)()); + return readLabel(tag); } @@ -144,14 +146,14 @@ void skipSection(IFstream& is) } -scalar readUnvScalar(const string& unvString) +scalar readUnvScalar(const std::string& unvString) { string s(unvString); s.replaceAll("d", "E"); s.replaceAll("D", "E"); - return readScalar(IStringStream(s)()); + return readScalar(s); } @@ -170,13 +172,13 @@ void readUnits string line; is.getLine(line); - label l = readLabel(IStringStream(line.substr(0, 10))()); + label l = readLabel(line.substr(0, 10)); Info<< "l:" << l << endl; string units(line.substr(10, 20)); Info<< "units:" << units << endl; - label unitType = readLabel(IStringStream(line.substr(30, 10))()); + label unitType = readLabel(line.substr(30, 10)); Info<< "unitType:" << unitType << endl; // Read lengthscales @@ -215,7 +217,7 @@ void readPoints string line; is.getLine(line); - label pointi = readLabel(IStringStream(line.substr(0, 10))()); + label pointi = readLabel(line.substr(0, 10)); if (pointi == -1) { diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C index c87d6f19cd..84fdfb1f3f 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C @@ -70,7 +70,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated } // const scalar timeValue = Foam::name(this->mesh().time().timeValue()); - const scalar timeValue = readScalar(IStringStream(timeDir)()); + const scalar timeValue = readScalar(timeDir); OFstream osCase(baseDir/surfName + ".case"); ensightGeoFile osGeom @@ -179,7 +179,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated // surfName already validated const fileName meshFile(baseDir/surfName + ".000000.mesh"); - const scalar timeValue = readScalar(IStringStream(timeDir)()); + const scalar timeValue = readScalar(timeDir); label timeIndex = 0; // Do case file @@ -194,7 +194,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated if (is.good() && dict.read(is)) { dict.lookup("times") >> times; - const scalar timeValue = readScalar(IStringStream(timeDir)()); + const scalar timeValue = readScalar(timeDir); label index = findLower(times, timeValue); timeIndex = index+1; }