STYLE: use readLabel/readScalar (string) instead of via IStringStream

This commit is contained in:
Mark Olesen
2017-11-13 11:23:17 +01:00
parent 817b9a14ba
commit 0ca0a6264b
2 changed files with 12 additions and 10 deletions

View File

@ -68,9 +68,11 @@ namespace Foam
return Hash<face>::operator()(t, 0); return Hash<face>::operator()(t, 0);
} }
} }
const string SEPARATOR(" -1"); const string SEPARATOR(" -1");
bool isSeparator(const string& line)
bool isSeparator(const std::string& line)
{ {
return line.substr(0, 6) == SEPARATOR; return line.substr(0, 6) == SEPARATOR;
} }
@ -100,7 +102,7 @@ label readTag(IFstream& is)
} while (tag == SEPARATOR); } 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); string s(unvString);
s.replaceAll("d", "E"); s.replaceAll("d", "E");
s.replaceAll("D", "E"); s.replaceAll("D", "E");
return readScalar(IStringStream(s)()); return readScalar(s);
} }
@ -170,13 +172,13 @@ void readUnits
string line; string line;
is.getLine(line); is.getLine(line);
label l = readLabel(IStringStream(line.substr(0, 10))()); label l = readLabel(line.substr(0, 10));
Info<< "l:" << l << endl; Info<< "l:" << l << endl;
string units(line.substr(10, 20)); string units(line.substr(10, 20));
Info<< "units:" << units << endl; Info<< "units:" << units << endl;
label unitType = readLabel(IStringStream(line.substr(30, 10))()); label unitType = readLabel(line.substr(30, 10));
Info<< "unitType:" << unitType << endl; Info<< "unitType:" << unitType << endl;
// Read lengthscales // Read lengthscales
@ -215,7 +217,7 @@ void readPoints
string line; string line;
is.getLine(line); is.getLine(line);
label pointi = readLabel(IStringStream(line.substr(0, 10))()); label pointi = readLabel(line.substr(0, 10));
if (pointi == -1) if (pointi == -1)
{ {

View File

@ -70,7 +70,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated
} }
// const scalar timeValue = Foam::name(this->mesh().time().timeValue()); // 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"); OFstream osCase(baseDir/surfName + ".case");
ensightGeoFile osGeom ensightGeoFile osGeom
@ -179,7 +179,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
// surfName already validated // surfName already validated
const fileName meshFile(baseDir/surfName + ".000000.mesh"); const fileName meshFile(baseDir/surfName + ".000000.mesh");
const scalar timeValue = readScalar(IStringStream(timeDir)()); const scalar timeValue = readScalar(timeDir);
label timeIndex = 0; label timeIndex = 0;
// Do case file // Do case file
@ -194,7 +194,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
if (is.good() && dict.read(is)) if (is.good() && dict.read(is))
{ {
dict.lookup("times") >> times; dict.lookup("times") >> times;
const scalar timeValue = readScalar(IStringStream(timeDir)()); const scalar timeValue = readScalar(timeDir);
label index = findLower(times, timeValue); label index = findLower(times, timeValue);
timeIndex = index+1; timeIndex = index+1;
} }