mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: use range-for in dictionary internals
This commit is contained in:
@ -156,14 +156,14 @@ Foam::dictionary::dictionary
|
|||||||
name_(dict.name()),
|
name_(dict.name()),
|
||||||
parent_(parentDict)
|
parent_(parentDict)
|
||||||
{
|
{
|
||||||
forAllIter(parent_type, *this, iter)
|
for (entry& e : *this)
|
||||||
{
|
{
|
||||||
hashedEntries_.insert(iter().keyword(), &iter());
|
hashedEntries_.insert(e.keyword(), &e);
|
||||||
|
|
||||||
if (iter().keyword().isPattern())
|
if (e.keyword().isPattern())
|
||||||
{
|
{
|
||||||
patterns_.insert(&iter());
|
patterns_.insert(&e);
|
||||||
regexps_.insert(autoPtr<regExp>::New(iter().keyword()));
|
regexps_.insert(autoPtr<regExp>::New(e.keyword()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,14 +178,14 @@ Foam::dictionary::dictionary
|
|||||||
name_(dict.name()),
|
name_(dict.name()),
|
||||||
parent_(dictionary::null)
|
parent_(dictionary::null)
|
||||||
{
|
{
|
||||||
forAllIter(parent_type, *this, iter)
|
for (entry& e : *this)
|
||||||
{
|
{
|
||||||
hashedEntries_.insert(iter().keyword(), &iter());
|
hashedEntries_.insert(e.keyword(), &e);
|
||||||
|
|
||||||
if (iter().keyword().isPattern())
|
if (e.keyword().isPattern())
|
||||||
{
|
{
|
||||||
patterns_.insert(&iter());
|
patterns_.insert(&e);
|
||||||
regexps_.insert(autoPtr<regExp>::New(iter().keyword()));
|
regexps_.insert(autoPtr<regExp>::New(e.keyword()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,9 +283,9 @@ Foam::SHA1Digest Foam::dictionary::digest() const
|
|||||||
OSHA1stream os;
|
OSHA1stream os;
|
||||||
|
|
||||||
// Process entries
|
// Process entries
|
||||||
forAllConstIter(parent_type, *this, iter)
|
for (const entry& e : *this)
|
||||||
{
|
{
|
||||||
os << *iter;
|
os << e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return os.digest();
|
return os.digest();
|
||||||
@ -298,9 +298,9 @@ Foam::tokenList Foam::dictionary::tokens() const
|
|||||||
OStringStream os;
|
OStringStream os;
|
||||||
|
|
||||||
// Process entries
|
// Process entries
|
||||||
forAllConstIter(parent_type, *this, iter)
|
for (const entry& e : *this)
|
||||||
{
|
{
|
||||||
os << *iter;
|
os << e;
|
||||||
}
|
}
|
||||||
|
|
||||||
// String re-parsed as a list of tokens
|
// String re-parsed as a list of tokens
|
||||||
@ -394,11 +394,9 @@ bool Foam::dictionary::substituteKeyword(const word& keyword, bool mergeEntry)
|
|||||||
// If defined insert its entries into this dictionary
|
// If defined insert its entries into this dictionary
|
||||||
if (finder.found())
|
if (finder.found())
|
||||||
{
|
{
|
||||||
const dictionary& addDict = finder.dict();
|
for (const entry& e : finder.dict())
|
||||||
|
|
||||||
forAllConstIters(addDict, iter)
|
|
||||||
{
|
{
|
||||||
add(iter(), mergeEntry);
|
add(e, mergeEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -428,11 +426,9 @@ bool Foam::dictionary::substituteScopedKeyword
|
|||||||
// If defined insert its entries into this dictionary
|
// If defined insert its entries into this dictionary
|
||||||
if (finder.found())
|
if (finder.found())
|
||||||
{
|
{
|
||||||
const dictionary& addDict = finder.dict();
|
for (const entry& e : finder.dict())
|
||||||
|
|
||||||
forAllConstIter(parent_type, addDict, iter)
|
|
||||||
{
|
{
|
||||||
add(iter(), mergeEntry);
|
add(e, mergeEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -570,9 +566,9 @@ Foam::wordList Foam::dictionary::toc() const
|
|||||||
wordList list(size());
|
wordList list(size());
|
||||||
|
|
||||||
label n = 0;
|
label n = 0;
|
||||||
forAllConstIters(*this, iter)
|
for (const entry& e : *this)
|
||||||
{
|
{
|
||||||
list[n++] = iter().keyword();
|
list[n++] = e.keyword();
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@ -590,11 +586,11 @@ Foam::List<Foam::keyType> Foam::dictionary::keys(bool patterns) const
|
|||||||
List<keyType> list(size());
|
List<keyType> list(size());
|
||||||
|
|
||||||
label n = 0;
|
label n = 0;
|
||||||
forAllConstIters(*this, iter)
|
for (const entry& e : *this)
|
||||||
{
|
{
|
||||||
if (iter().keyword().isPattern() ? patterns : !patterns)
|
if (e.keyword().isPattern() ? patterns : !patterns)
|
||||||
{
|
{
|
||||||
list[n++] = iter().keyword();
|
list[n++] = e.keyword();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.resize(n);
|
list.resize(n);
|
||||||
@ -783,31 +779,31 @@ bool Foam::dictionary::merge(const dictionary& dict)
|
|||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
forAllConstIters(dict, iter)
|
for (const entry& e : dict)
|
||||||
{
|
{
|
||||||
auto fnd = hashedEntries_.find(iter().keyword());
|
auto fnd = hashedEntries_.find(e.keyword());
|
||||||
|
|
||||||
if (fnd.found())
|
if (fnd.found())
|
||||||
{
|
{
|
||||||
// Recursively merge sub-dictionaries
|
// Recursively merge sub-dictionaries
|
||||||
// TODO: merge without copying
|
// TODO: merge without copying
|
||||||
if (fnd()->isDict() && iter().isDict())
|
if (fnd()->isDict() && e.isDict())
|
||||||
{
|
{
|
||||||
if (fnd()->dict().merge(iter().dict()))
|
if (fnd()->dict().merge(e.dict()))
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
add(iter().clone(*this).ptr(), true);
|
add(e.clone(*this).ptr(), true);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Not found - just add
|
// Not found - just add
|
||||||
add(iter().clone(*this).ptr());
|
add(e.clone(*this).ptr());
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -855,9 +851,9 @@ void Foam::dictionary::operator=(const dictionary& rhs)
|
|||||||
// Create clones of the entries in the given dictionary
|
// Create clones of the entries in the given dictionary
|
||||||
// resetting the parentDict to this dictionary
|
// resetting the parentDict to this dictionary
|
||||||
|
|
||||||
forAllConstIters(rhs, iter)
|
for (const entry& e : rhs)
|
||||||
{
|
{
|
||||||
add(iter().clone(*this).ptr());
|
add(e.clone(*this).ptr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -872,9 +868,9 @@ void Foam::dictionary::operator+=(const dictionary& rhs)
|
|||||||
<< abort(FatalIOError);
|
<< abort(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
forAllConstIters(rhs, iter)
|
for (const entry& e : rhs)
|
||||||
{
|
{
|
||||||
add(iter().clone(*this).ptr());
|
add(e.clone(*this).ptr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -889,11 +885,11 @@ void Foam::dictionary::operator|=(const dictionary& rhs)
|
|||||||
<< abort(FatalIOError);
|
<< abort(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
forAllConstIters(rhs, iter)
|
for (const entry& e : rhs)
|
||||||
{
|
{
|
||||||
if (!found(iter().keyword()))
|
if (!found(e.keyword()))
|
||||||
{
|
{
|
||||||
add(iter().clone(*this).ptr());
|
add(e.clone(*this).ptr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -909,9 +905,9 @@ void Foam::dictionary::operator<<=(const dictionary& rhs)
|
|||||||
<< abort(FatalIOError);
|
<< abort(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
forAllConstIters(rhs, iter)
|
for (const entry& e : rhs)
|
||||||
{
|
{
|
||||||
set(iter().clone(*this).ptr());
|
set(e.clone(*this).ptr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -169,10 +169,8 @@ void Foam::dictionary::writeEntry(const keyType& kw, Ostream& os) const
|
|||||||
|
|
||||||
void Foam::dictionary::writeEntries(Ostream& os, const bool extraNewLine) const
|
void Foam::dictionary::writeEntries(Ostream& os, const bool extraNewLine) const
|
||||||
{
|
{
|
||||||
forAllConstIter(parent_type, *this, iter)
|
for (const entry& e : *this)
|
||||||
{
|
{
|
||||||
const entry& e = *iter;
|
|
||||||
|
|
||||||
// Write entry
|
// Write entry
|
||||||
os << e;
|
os << e;
|
||||||
|
|
||||||
@ -187,7 +185,7 @@ void Foam::dictionary::writeEntries(Ostream& os, const bool extraNewLine) const
|
|||||||
if (!os.good())
|
if (!os.good())
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Can't write entry " << iter().keyword()
|
<< "Can't write entry " << e.keyword()
|
||||||
<< " for dictionary " << name()
|
<< " for dictionary " << name()
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user