mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: use range-for when looping dictionary entries.
- as part of the cleanup of dictionary access methods (c6520033c9)
made the dictionary class single inheritance from IDLList<entry>.
This eliminates any ambiguities for iterators and allows
for simple use of range-for looping.
Eg,
for (const entry& e : topDict))
{
Info<< "entry:" << e.keyword() << " is dict:" << e.isDict() << nl;
}
vs
forAllConstIter(dictionary, topDict, iter))
{
Info<< "entry:" << iter().keyword()
<< " is dict:" << iter().isDict() << nl;
}
This commit is contained in:
@ -106,11 +106,11 @@ bool Foam::functionObjects::runTimePostProcessing::read(const dictionary& dict)
|
||||
readObjects(dict.subOrEmptyDict("lines"), lines_);
|
||||
readObjects(dict.subOrEmptyDict("surfaces"), surfaces_);
|
||||
|
||||
|
||||
const dictionary& textDict = dict.subDict("text");
|
||||
forAllConstIter(dictionary, textDict, iter)
|
||||
|
||||
for (const entry& dEntry : textDict)
|
||||
{
|
||||
if (!iter().isDict())
|
||||
if (!dEntry.isDict())
|
||||
{
|
||||
FatalIOErrorInFunction(textDict)
|
||||
<< "text must be specified in dictionary format"
|
||||
@ -122,7 +122,7 @@ bool Foam::functionObjects::runTimePostProcessing::read(const dictionary& dict)
|
||||
new runTimePostPro::text
|
||||
(
|
||||
*this,
|
||||
iter().dict(),
|
||||
dEntry.dict(),
|
||||
scene_.colours()
|
||||
)
|
||||
);
|
||||
|
||||
@ -33,9 +33,10 @@ void Foam::functionObjects::runTimePostProcessing::readObjects
|
||||
) const
|
||||
{
|
||||
objects.clear();
|
||||
forAllConstIter(dictionary, dict, iter)
|
||||
|
||||
for (const entry& dEntry : dict)
|
||||
{
|
||||
if (!iter().isDict())
|
||||
if (!dEntry.isDict())
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< dict.dictName()
|
||||
@ -43,12 +44,12 @@ void Foam::functionObjects::runTimePostProcessing::readObjects
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
const dictionary& objectDict(iter().dict());
|
||||
const dictionary& objectDict = dEntry.dict();
|
||||
const word objectType = objectDict.get<word>("type");
|
||||
|
||||
objects.append
|
||||
(
|
||||
Type::New(*this, iter().dict(), scene_.colours(), objectType)
|
||||
Type::New(*this, objectDict, scene_.colours(), objectType)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user