ENH: add dictionary optionalSubDict() method as per .org change (20-Apr)

This commit is contained in:
Mark Olesen
2017-05-10 12:51:21 +02:00
parent cd8083eb95
commit 4d126bfe2d
2 changed files with 22 additions and 0 deletions

View File

@ -743,6 +743,24 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict
} }
const Foam::dictionary& Foam::dictionary::optionalSubDict
(
const word& keyword
) const
{
const entry* entryPtr = lookupEntryPtr(keyword, false, true);
if (entryPtr)
{
return entryPtr->dict();
}
else
{
return *this;
}
}
Foam::wordList Foam::dictionary::toc() const Foam::wordList Foam::dictionary::toc() const
{ {
wordList keys(size()); wordList keys(size());

View File

@ -436,6 +436,10 @@ public:
const bool mustRead = false const bool mustRead = false
) const; ) const;
//- Find and return a sub-dictionary if found
// otherwise return this dictionary
const dictionary& optionalSubDict(const word& keyword) const;
//- Return the table of contents //- Return the table of contents
wordList toc() const; wordList toc() const;