// Reads past -1 and reads element type label readTag(IFstream& is) { string tag; do { if (!is.good()) { return -1; } string line; is.getLine(line); if (line.size() < 6) { return -1; } tag = line.substr(0, 6); } while (tag == SEPARATOR); return readLabel(IStringStream(tag)()); }
bool Foam::meshReaders::STARCD::readHeader(IFstream& is, word fileSignature) { if (!is.good()) { FatalErrorInFunction << abort(FatalError); } word header; label majorVersion; is >> header; is >> majorVersion; // skip the rest of the line readToNewline(is); // add other checks ... if (header != fileSignature) { Info<< "header mismatch " << fileSignature << " " << is.name() << endl; } return true; }
// Read up to line starting with cmd. Sets args to rest of line. // Returns true if found, false if stream is not good anymore. bool Foam::fileFormats::AC3DsurfaceFormatCore::cueTo ( IFstream& is, const string& cmd, string& args ) { while (is.good()) { string line; is.getLine(line); string::size_type space = line.find(' '); if (space != string::npos) { if (line.substr(0, space) == cmd) { args = line.substr(space+1); return true; } } } return false; }
Foam::string Foam::fileFormats::surfaceFormatsCore::getLineNoComment ( IFstream& is ) { string line; do { is.getLine(line); } while ((line.empty() || line[0] == '#') && is.good()); return line; }
// Skip void skipSection(IFstream& is) { Info<< "Skipping section at line " << is.lineNumber() << '.' << endl; string line; while (is.good()) { is.getLine(line); if (isSeparator(line)) { break; } } }
// Skips till end of section. Returns false if end of file. bool skipSection(IFstream& inFile) { string line; do { inFile.getLine(line); if (!inFile.good()) { return false; } } while (line.size() < 4 || line.substr(0, 4) != "$End"); return true; }
// Reads and prints header void readHeader(IFstream& is) { string line; while (is.good()) { is.getLine(line); if (isSeparator(line)) { break; } else { Sout<< line << endl; } } }
static bool readCmd(IFstream& ACfile, string& cmd, string& args) { if (ACfile.good()) { string line; ACfile.getLine(line); string::size_type space = line.find(' '); if (space != string::npos) { cmd = line.substr(0, space); args = line.substr(space+1); return true; } } return false; }
Foam::Istream* Foam::IOobject::objectStream(const fileName& fName) { if (fName.size()) { IFstream* isPtr = new IFstream(fName); if (isPtr->good()) { return isPtr; } else { delete isPtr; return NULL; } } else { return NULL; } }
// Read up to line starting with cmd. Sets args to rest of line. // Returns true if found, false if stream is not good anymore. static bool readUpto ( const string& cmd, IFstream& ACfile, string& args ) { while (ACfile.good()) { string line; ACfile.getLine(line); string::size_type space = line.find(' '); if (space != string::npos && line.substr(0, space) == cmd) { args = line.substr(space+1); return true; } } return false; }
Foam::Istream* Foam::IOobject::objectStream() { fileName fName = filePath(); if (fName.size()) { IFstream* isPtr = new IFstream(fName); if (isPtr->good()) { return isPtr; } else { delete isPtr; return NULL; } } else { return NULL; } }
bool Foam::fileFormats::AC3DsurfaceFormatCore::readCmd ( IFstream& is, string& cmd, string& args ) { if (is.good()) { string line; is.getLine(line); string::size_type space = line.find(' '); if (space != string::npos) { cmd = line.substr(0, space); args = line.substr(space+1); return true; } } return false; }