bool Foam::functionEntries::codeStream::execute ( const dictionary& parentDict, primitiveEntry& entry, Istream& is ) { Info<< "Using #codeStream at line " << is.lineNumber() << " in file " << parentDict.name() << endl; dynamicCode::checkSecurity ( "functionEntries::codeStream::execute(..)", parentDict ); // get code dictionary // must reference parent for stringOps::expand to work nicely dictionary codeDict("#codeStream", parentDict, is); streamingFunctionType function = getFunction(parentDict, codeDict); // use function to write stream OStringStream os(is.format()); (*function)(os, parentDict); // get the entry from this stream IStringStream resultStream(os.str()); entry.read(parentDict, resultStream); return true; }
bool Foam::functionEntries::includeEntry::execute ( const dictionary& parentDict, primitiveEntry& entry, Istream& is ) { const fileName fName(includeFileName(is)); IFstream ifs(fName); if (ifs) { if (Foam::functionEntries::includeEntry::report) { Info<< fName << endl; } entry.read(parentDict, ifs); return true; } else { FatalIOErrorIn ( "functionEntries::includeEntry::includeEntry" "(dictionary& parentDict, primitiveEntry&, Istream&)", is ) << "Cannot open include file " << ifs.name() << " while reading dictionary " << parentDict.name() << exit(FatalIOError); return false; } }
bool Foam::functionEntries::negEntry::execute ( const dictionary& parentDict, primitiveEntry& thisEntry, Istream& is ) { // Reinsert negated variable into entry IStringStream resultStream(negateVariable(parentDict, is)); thisEntry.read(parentDict, resultStream); return true; }
bool Foam::functionEntries::calcEntry::execute ( const dictionary& parentDict, primitiveEntry& entry, Istream& is ) { dictionary args(parentDict, is); OStringStream resultStream; resultStream << (args.lookup("x")[0].number() + args.lookup("y")[0].number()); entry.read(parentDict, IStringStream(resultStream.str())()); return true; }
bool Foam::functionEntries::includeIfPresentEntry::execute ( const dictionary& parentDict, primitiveEntry& entry, Istream& is ) { IFstream ifs(includeFileName(is)); if (ifs) { entry.read(parentDict, ifs); } return true; }
bool Foam::functionEntries::includeEntry::execute ( const dictionary& parentDict, primitiveEntry& entry, Istream& is ) { const fileName rawFName(is); const fileName fName ( includeFileName(is.name().path(), rawFName, parentDict) ); IFstream ifs(fName); if (ifs) { if (Foam::functionEntries::includeEntry::log) { Info<< fName << endl; } entry.read(parentDict, ifs); return true; } else { FatalIOErrorInFunction ( is ) << "Cannot open include file " << (ifs.name().size() ? ifs.name() : rawFName) << " while reading dictionary " << parentDict.name() << exit(FatalIOError); return false; } }