T Foam::dictionary::lookupOrAddDefault ( const word& keyword, const T& deflt, bool recursive, bool patternMatch ) { const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch); if (entryPtr) { return pTraits<T>(entryPtr->stream()); } else { if (writeOptionalEntries) { IOInfoInFunction(*this) << "Optional entry '" << keyword << "' is not present," << " adding and returning the default value '" << deflt << "'" << endl; } add(new primitiveEntry(keyword, deflt)); return deflt; } }
bool Foam::dictionary::readIfPresent ( const word& k, T& val, bool recursive, bool patternMatch ) const { const entry* entryPtr = lookupEntryPtr(k, recursive, patternMatch); if (entryPtr) { entryPtr->stream() >> val; return true; } else { return false;
bool Foam::dictionary::readIfPresent ( const word& keyword, T& val, bool recursive, bool patternMatch ) const { const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch); if (entryPtr) { entryPtr->stream() >> val; return true; } else { if (writeOptionalEntries)
T Foam::dictionary::lookupOrDefault ( const word& keyword, const T& deflt, bool recursive, bool patternMatch ) const { const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch); if (entryPtr) { return pTraits<T>(entryPtr->stream()); } else { return deflt; } }
T Foam::dictionary::lookupType ( const word& keyword, bool recursive, bool patternMatch ) const { const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch); if (entryPtr == nullptr) { FatalIOErrorInFunction ( *this ) << "keyword " << keyword << " is undefined in dictionary " << name() << exit(FatalIOError); } return pTraits<T>(entryPtr->stream()); }