unsigned char Foam::SHA1Digest::readHexDigit(Istream& is) { // Takes into account that 'a' (or 'A') is 10 static const int alphaOffset = toupper('A') - 10; // Takes into account that '0' is 0 static const int zeroOffset = int('0'); // silently ignore leading or intermediate '_' char c = 0; do { is.read(c); } while (c == '_'); if (!isxdigit(c)) { FatalIOErrorIn("SHA1Digest::readHexDigit(Istream&)", is) << "Illegal hex digit: '" << c << "'" << exit(FatalIOError); } if (isdigit(c)) { return int(c) - zeroOffset; } else { return toupper(c) - alphaOffset; } }
static void load_data_record(Istream& fin, const gcstring& table, int tran, int n) { try { if (n > loadbuf_size) { loadbuf_size = max(n, 2 * loadbuf_size); mem_release(loadbuf); loadbuf = (char*) mem_committed(loadbuf_size); verify(loadbuf); } fin.read(loadbuf, n); Record rec(loadbuf); if (rec.cursize() != n) except_err(table << ": rec size " << rec.cursize() << " not what was read " << n); if (table == "views") theDB()->add_any_record(tran, table, rec); else theDB()->add_record(tran, table, rec); } catch (const Except& e) { errlog("load: skipping corrupted record in: ", table.str(), e.str()); alert("skipping corrupted record in: " << table << ": " << e); alerts = true; } }
Foam::WetParcel<ParcelType>::WetParcel ( const polyMesh& mesh, Istream& is, bool readFields ) : ParcelType(mesh, is, readFields), Vliq_(0.0) { if (readFields) { if (is.format() == IOstream::ASCII) { Vliq_ = readScalar(is); } else { is.read ( reinterpret_cast<char*>(&Vliq_), sizeof(Vliq_) ); } } // Check state of Istream is.check ( "WetParcel<ParcelType>::WetParcel" "(const polyMesh&, Istream&, bool)" ); }
bool Foam::entry::getKeyword(keyType& keyword, Istream& is) { token keywordToken; // Read the next valid token discarding spurious ';'s do { if ( is.read(keywordToken).bad() || is.eof() || !keywordToken.good() ) { return false; } } while (keywordToken == token::END_STATEMENT); // If the token is a valid keyword set 'keyword' return true... if (keywordToken.isWord()) { keyword = keywordToken.wordToken(); return true; } else if (keywordToken.isString()) { // Enable wildcards keyword = keywordToken.stringToken(); return true; } // If it is the end of the dictionary or file return false... else if (keywordToken == token::END_BLOCK || is.eof()) { return false; } // Otherwise the token is invalid else { cerr<< "--> FOAM Warning : " << std::endl << " From function " << "entry::getKeyword(keyType&, Istream&)" << std::endl << " in file " << __FILE__ << " at line " << __LINE__ << std::endl << " Reading " << is.name().c_str() << std::endl << " found " << keywordToken << std::endl << " expected either " << token::END_BLOCK << " or EOF" << std::endl; return false; } }
void Foam::functionEntries::ifeqEntry::readToken(token& t, Istream& is) { // Skip dummy tokens - avoids entry::getKeyword consuming #else, #endif do { if ( is.read(t).bad() || is.eof() || !t.good() ) { return; } } while (t == token::END_STATEMENT); }
static int load_data(Istream& fin, const gcstring& table) { int nrecs = 0; int tran = theDB()->transaction(READWRITE); for (;; ++nrecs) { int n; fin.read((char*) &n, sizeof n); if (fin.gcount() != sizeof n) except("unexpected eof"); if (n == 0) break ; load_data_record(fin, table, tran, n); if (nrecs % recsPerTran == recsPerTran - 1) { verify(theDB()->commit(tran)); tran = theDB()->transaction(READWRITE); } } verify(theDB()->commit(tran)); return nrecs; }
Foam::ThermoParcel<ParcelType>::ThermoParcel ( const Cloud<ParcelType>& cloud, Istream& is, bool readFields ) : KinematicParcel<ParcelType>(cloud, is, readFields), T_(0.0), cp_(0.0), Tc_(0.0), cpc_(0.0) { if (readFields) { if (is.format() == IOstream::ASCII) { T_ = readScalar(is); cp_ = readScalar(is); } else { is.read ( reinterpret_cast<char*>(&T_), + sizeof(T_) + sizeof(cp_) ); } } // Check state of Istream is.check ( "ThermoParcel::ThermoParcel(const Cloud<ParcelType>&, Istream&, bool)" ); }
Foam::token::token(Istream& is) : type_(UNDEFINED) { is.read(*this); }
bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is) { is.fatalCheck ( "primitiveEntry::readData(const dictionary&, Istream&)" ); label blockCount = 0; token currToken; if ( !is.read(currToken).bad() && currToken.good() && currToken != token::END_STATEMENT ) { append(currToken, dict, is); if ( currToken == token::BEGIN_BLOCK || currToken == token::BEGIN_LIST ) { blockCount++; } while ( !is.read(currToken).bad() && currToken.good() && !(currToken == token::END_STATEMENT && blockCount == 0) ) { if ( currToken == token::BEGIN_BLOCK || currToken == token::BEGIN_LIST ) { blockCount++; } else if ( currToken == token::END_BLOCK || currToken == token::END_LIST ) { blockCount--; } append(currToken, dict, is); } } is.fatalCheck ( "primitiveEntry::readData(const dictionary&, Istream&)" ); if (currToken.good()) { return true; } else { return false; } }
Foam::WetParcel<ParcelType>::WetParcel ( const polyMesh& mesh, Istream& is, bool readFields ) : ParcelType(mesh, is, readFields), Vliq_(0.0), partVliq_(), liquidPositionVectors_(), liquidPositions_(), contactList_(), previousContactList_() { if (readFields) { if (is.format() == IOstream::ASCII) { Vliq_ = readScalar(is); partVliq_ = readList<scalar>(is); liquidPositions_ = readList<vector>(is); liquidPositionVectors_ = readList<vector>(is); contactList_ = readList<label>(is); previousContactList_ = readList<label>(is); } else { /* is.read ( reinterpret_cast<char*>(&Vliq_), sizeof(Vliq_) ); is.read ( reinterpret_cast<char*>(&partVliq_), sizeof(partVliq_) ); is.read ( reinterpret_cast<char*>(&liquidPositions_), sizeof(liquidPositions_) ); is.read ( reinterpret_cast<char*>(&liquidPositionVectors_), sizeof(liquidPositionVectors_) ); */ is.read ( reinterpret_cast<char*>(&Vliq_), sizeof(Vliq_) +sizeof(partVliq_) +sizeof(liquidPositionVectors_) +sizeof(liquidPositions_) +sizeof(contactList_) +sizeof(previousContactList_) ); } } // Check state of Istream is.check ( "WetParcel<ParcelType>::WetParcel" "(const polyMesh&, Istream&, bool)" ); }