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:
@ -187,13 +187,13 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection
|
||||
|
||||
label surfI = 0;
|
||||
label startIndex = 0;
|
||||
forAllConstIter(dictionary, dict, iter)
|
||||
for (const entry& dEntry : dict)
|
||||
{
|
||||
if (dict.isDict(iter().keyword()))
|
||||
if (dEntry.isDict())
|
||||
{
|
||||
instance_[surfI] = iter().keyword();
|
||||
instance_[surfI] = dEntry.keyword();
|
||||
|
||||
const dictionary& subDict = dict.subDict(instance_[surfI]);
|
||||
const dictionary& subDict = dEntry.dict();
|
||||
|
||||
subDict.readEntry("scale", scale_[surfI]);
|
||||
transform_.set
|
||||
|
||||
@ -119,14 +119,12 @@ Foam::searchableSurfaces::searchableSurfaces(const label size)
|
||||
// {
|
||||
// const dictionary& regionsDict = dict.subDict("regions");
|
||||
//
|
||||
// forAllConstIter(dictionary, regionsDict, iter)
|
||||
// for (const entry& dEntry : regionsDict)
|
||||
// {
|
||||
// const word& key = iter().keyword();
|
||||
//
|
||||
// if (regionsDict.isDict(key))
|
||||
// if (dEntry.isDict())
|
||||
// {
|
||||
// // Get the dictionary for region iter.key()
|
||||
// const dictionary& regionDict = regionsDict.subDict(key);
|
||||
// const word& key = dEntry.keyword();
|
||||
// const dictionary& regionDict = dEntry.dict();
|
||||
//
|
||||
// label index = localNames.find(key);
|
||||
//
|
||||
@ -178,18 +176,18 @@ Foam::searchableSurfaces::searchableSurfaces
|
||||
allSurfaces_(identity(topDict.size()))
|
||||
{
|
||||
label surfI = 0;
|
||||
forAllConstIter(dictionary, topDict, iter)
|
||||
{
|
||||
const word& key = iter().keyword();
|
||||
|
||||
if (!topDict.isDict(key))
|
||||
for (const entry& dEntry : topDict)
|
||||
{
|
||||
if (!dEntry.isDict())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Found non-dictionary entry " << iter()
|
||||
<< "Found non-dictionary entry " << dEntry
|
||||
<< " in top-level dictionary " << topDict
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const word& key = dEntry.keyword();
|
||||
const dictionary& dict = topDict.subDict(key);
|
||||
|
||||
names_[surfI] = dict.lookupOrDefault<word>("name", key);
|
||||
@ -240,14 +238,12 @@ Foam::searchableSurfaces::searchableSurfaces
|
||||
{
|
||||
const dictionary& regionsDict = dict.subDict("regions");
|
||||
|
||||
forAllConstIter(dictionary, regionsDict, iter)
|
||||
for (const entry& dEntry : regionsDict)
|
||||
{
|
||||
const word& key = iter().keyword();
|
||||
|
||||
if (regionsDict.isDict(key))
|
||||
if (dEntry.isDict())
|
||||
{
|
||||
// Get the dictionary for region iter.keyword()
|
||||
const dictionary& regionDict = regionsDict.subDict(key);
|
||||
const word& key = dEntry.keyword();
|
||||
const dictionary& regionDict = dEntry.dict();
|
||||
|
||||
label index = localNames.find(key);
|
||||
|
||||
@ -255,8 +251,9 @@ Foam::searchableSurfaces::searchableSurfaces
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown region name " << key
|
||||
<< " for surface " << s.name() << endl
|
||||
<< " for surface " << s.name() << nl
|
||||
<< "Valid region names are " << localNames
|
||||
<< endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user