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:
Mark Olesen
2018-10-19 13:08:24 +02:00
parent 4e04c1966f
commit 07dafe7b0b
60 changed files with 636 additions and 653 deletions

View File

@ -136,18 +136,19 @@ Foam::rigidBodyMeshMotion::rigidBodyMeshMotion
const dictionary& bodiesDict = coeffDict().subDict("bodies");
forAllConstIter(IDLList<entry>, bodiesDict, iter)
for (const entry& dEntry : bodiesDict)
{
const dictionary& bodyDict = iter().dict();
const keyType& bodyName = dEntry.keyword();
const dictionary& bodyDict = dEntry.dict();
if (bodyDict.found("patches"))
{
const label bodyID = model_.bodyID(iter().keyword());
const label bodyID = model_.bodyID(bodyName);
if (bodyID == -1)
{
FatalErrorInFunction
<< "Body " << iter().keyword()
<< "Body " << bodyName
<< " has been merged with another body"
" and cannot be assigned a set of patches"
<< exit(FatalError);
@ -158,7 +159,7 @@ Foam::rigidBodyMeshMotion::rigidBodyMeshMotion
new bodyMesh
(
mesh,
iter().keyword(),
bodyName,
bodyID,
bodyDict
)

View File

@ -127,18 +127,19 @@ Foam::rigidBodyMeshMotionSolver::rigidBodyMeshMotionSolver
const dictionary& bodiesDict = coeffDict().subDict("bodies");
forAllConstIter(IDLList<entry>, bodiesDict, iter)
for (const entry& dEntry : bodiesDict)
{
const dictionary& bodyDict = iter().dict();
const keyType& bodyName = dEntry.keyword();
const dictionary& bodyDict = dEntry.dict();
if (bodyDict.found("patches"))
{
const label bodyID = model_.bodyID(iter().keyword());
const label bodyID = model_.bodyID(bodyName);
if (bodyID == -1)
{
FatalErrorInFunction
<< "Body " << iter().keyword()
<< "Body " << bodyName
<< " has been merged with another body"
" and cannot be assigned a set of patches"
<< exit(FatalError);
@ -149,7 +150,7 @@ Foam::rigidBodyMeshMotionSolver::rigidBodyMeshMotionSolver
new bodyMesh
(
mesh,
iter().keyword(),
bodyName,
bodyID,
bodyDict
)