Foam::OFstream::OFstream ( const fileName& pathname, streamFormat format, versionNumber version, compressionType compression ) : OFstreamAllocator(pathname, compression), OSstream(*ofPtr_, "OFstream.sinkFile_", format, version, compression), pathname_(pathname) { setClosed(); setState(ofPtr_->rdstate()); if (!good()) { if (debug) { Info<< "IFstream::IFstream(const fileName&," "streamFormat format=ASCII," "versionNumber version=currentVersion) : " "could not open file for input\n" "in stream " << info() << Foam::endl; } setBad(); } else { setOpened(); } lineNumber_ = 1; }
Istream& ITstream::read(token& t) { // Return the put back token if it exists if (Istream::getBack(t)) { lineNumber_ = t.lineNumber(); return *this; } if (tokenIndex_ < size()) { t = operator[](tokenIndex_++); lineNumber_ = t.lineNumber(); if (tokenIndex_ == size()) { setEof(); } } else { if (eof()) { FatalIOErrorIn ( "ITstream::read(token& t)", *this ) << "attempt to read beyond EOF" << exit(FatalIOError); setBad(); } else { setEof(); } if (size()) { token::undefinedToken.lineNumber() = operator[](size() - 1).lineNumber(); } else { token::undefinedToken.lineNumber() = lineNumber(); } t = token::undefinedToken; } return *this; }
Istream& Istream::readBegin(const char* funcName) { token delimiter(*this); if (delimiter != token::BEGIN_LIST) { setBad(); FatalIOErrorIn("Istream::readBegin(const char*)", *this) << "Expected a " << '\'' << token:: BEGIN_LIST << '\'' << " while reading " << funcName << ", found " << delimiter.info() << exit(FatalIOError); } return *this; }
Foam::Istream& Foam::Istream::readEnd(const char* funcName) { token delimiter(*this); if (delimiter != token::END_LIST) { setBad(); FatalIOErrorIn("Istream::readEnd(const char*)", *this) << "Expected a '" << token::END_LIST << "' while reading " << funcName << ", found " << delimiter.info() << exit(FatalIOError); } return *this; }
char Istream::readEndList(const char* funcName) { token delimiter(*this); if (delimiter != token::END_LIST && delimiter != token::END_BLOCK) { setBad(); FatalIOErrorIn("Istream::readEndList(const char*)", *this) << "Expected a " << '\'' << token::END_LIST << '\'' << " or a " << '\'' << token::END_BLOCK << '\'' << " while reading " << funcName << ", found " << delimiter.info() << exit(FatalIOError); return '\0'; } return delimiter.pToken(); }
char Foam::Istream::readBeginList(const char* funcName) { token delimiter(*this); if (delimiter != token::BEGIN_LIST && delimiter != token::BEGIN_BLOCK) { setBad(); FatalIOErrorIn("Istream::readBeginList(const char*)", *this) << "Expected a '" << token::BEGIN_LIST << "' or a '" << token::BEGIN_BLOCK << "' while reading " << funcName << ", found " << delimiter.info() << exit(FatalIOError); return '\0'; } return delimiter.pToken(); }
Foam::IFstream::IFstream ( const fileName& pathname, streamFormat format, versionNumber version ) : IFstreamAllocator(pathname), ISstream ( *ifPtr_, "IFstream.sourceFile_", format, version, IFstreamAllocator::compression_ ), pathname_(pathname) { setClosed(); setState(ifPtr_->rdstate()); if (!good()) { if (debug) { Info<< "IFstream::IFstream(const fileName&," "streamFormat=ASCII," "versionNumber=currentVersion) : " "could not open file for input" << endl << info() << endl; } setBad(); } else { setOpened(); } lineNumber_ = 1; }
Foam::Ostream& Foam::UOPstream::write(const token& t) { // Raw token output only supported for verbatim strings for now if (t.type() == token::VERBATIMSTRING) { write(char(token::VERBATIMSTRING)); write(t.stringToken()); } else if (t.type() == token::VARIABLE) { write(char(token::VARIABLE)); write(t.stringToken()); } else { notImplemented("Ostream& UOPstream::write(const token&)"); setBad(); } return *this; }
Foam::Istream& Foam::UIPstream::read(token& t) { // Return the put back token if it exists if (Istream::getBack(t)) { return *this; } char c; // return on error if (!read(c)) { t.setBad(); return *this; } // Set the line number of this token to the current stream line number t.lineNumber() = lineNumber(); // Analyse input starting with this character. switch (c) { // Punctuation case token::END_STATEMENT : case token::BEGIN_LIST : case token::END_LIST : case token::BEGIN_SQR : case token::END_SQR : case token::BEGIN_BLOCK : case token::END_BLOCK : case token::COLON : case token::COMMA : case token::ASSIGN : case token::ADD : case token::SUBTRACT : case token::MULTIPLY : case token::DIVIDE : { t = token::punctuationToken(c); return *this; } // Word case token::WORD : { word* pval = new word; if (read(*pval)) { if (token::compound::isCompound(*pval)) { t = token::compound::New(*pval, *this).ptr(); delete pval; } else { t = pval; } } else { delete pval; t.setBad(); } return *this; } // String case token::VERBATIMSTRING : { // Recurse to read actual string read(t); t.type() = token::VERBATIMSTRING; return *this; } case token::VARIABLE : { // Recurse to read actual string read(t); t.type() = token::VARIABLE; return *this; } case token::STRING : { string* pval = new string; if (read(*pval)) { t = pval; if (c == token::VERBATIMSTRING) { t.type() = token::VERBATIMSTRING; } } else { delete pval; t.setBad(); } return *this; } // Label case token::LABEL : { label val; if (read(val)) { t = val; } else { t.setBad(); } return *this; } // floatScalar case token::FLOAT_SCALAR : { floatScalar val; if (read(val)) { t = val; } else { t.setBad(); } return *this; } // doubleScalar case token::DOUBLE_SCALAR : { doubleScalar val; if (read(val)) { t = val; } else { t.setBad(); } return *this; } // Character (returned as a single character word) or error default: { if (isalpha(c)) { t = word(c); return *this; } setBad(); t.setBad(); return *this; } } }
void TermUnifier::failUnification() { setBad(true); term.clear(); lcuItems.clear(); }
void MapPoint::eraseObservation(const PtrKeyFrame& pKF){ mObservations.erase(pKF); if(!mbBad && mObservations.size()<3){ setBad(); } }
Foam::Ostream& Foam::OPstream::write(const token&) { notImplemented("Ostream& OPstream::write(const token&)"); setBad(); return *this; }