diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index a757caebcc..8c351510e7 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -117,12 +117,7 @@ Foam::dictionary::dictionary name_(dict.name()), parent_(parentDict) { - for - ( - IDLList::iterator iter = begin(); - iter != end(); - ++iter - ) + forAllIter(IDLList, *this, iter) { hashedEntries_.insert(iter().keyword(), &iter()); @@ -147,12 +142,7 @@ Foam::dictionary::dictionary name_(dict.name()), parent_(dictionary::null) { - for - ( - IDLList::iterator iter = begin(); - iter != end(); - ++iter - ) + forAllIter(IDLList, *this, iter) { hashedEntries_.insert(iter().keyword(), &iter()); @@ -238,12 +228,7 @@ Foam::SHA1Digest Foam::dictionary::digest() const OSHA1stream os; // process entries - for - ( - IDLList::const_iterator iter = begin(); - iter != end(); - ++iter - ) + forAllConstIter(IDLList, *this, iter) { os << *iter; } @@ -262,7 +247,8 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const { if (patternEntries_.size()) { - DLList::const_iterator wcLink = patternEntries_.begin(); + DLList::const_iterator wcLink = + patternEntries_.begin(); DLList >::const_iterator reLink = patternRegexps_.begin(); @@ -475,12 +461,7 @@ Foam::wordList Foam::dictionary::toc() const wordList keys(size()); label nKeys = 0; - for - ( - IDLList::const_iterator iter = begin(); - iter != end(); - ++iter - ) + forAllConstIter(IDLList::const_iterator, *this, iter) { keys[nKeys++] = iter().keyword(); } @@ -494,12 +475,7 @@ Foam::List Foam::dictionary::keys(bool patterns) const List keys(size()); label nKeys = 0; - for - ( - IDLList::const_iterator iter = begin(); - iter != end(); - ++iter - ) + forAllConstIter(IDLList, *this, iter) { if (iter().keyword().isPattern() ? patterns : !patterns) { @@ -665,8 +641,10 @@ bool Foam::dictionary::remove(const word& Keyword) if (iter != hashedEntries_.end()) { // Delete from patterns first - DLList::iterator wcLink = patternEntries_.begin(); - DLList >::iterator reLink = patternRegexps_.begin(); + DLList::iterator wcLink = + patternEntries_.begin(); + DLList >::iterator reLink = + patternRegexps_.begin(); // Find in pattern using exact match only if (findInPatterns(false, Keyword, wcLink, reLink)) @@ -792,12 +770,7 @@ bool Foam::dictionary::merge(const dictionary& dict) bool changed = false; - for - ( - IDLList::const_iterator iter = dict.begin(); - iter != dict.end(); - ++iter - ) + forAllConstIter(IDLList, *this, iter) { HashTable::iterator fnd = hashedEntries_.find(iter().keyword()); @@ -882,12 +855,7 @@ void Foam::dictionary::operator=(const dictionary& rhs) // Create clones of the entries in the given dictionary // resetting the parentDict to this dictionary - for - ( - IDLList::const_iterator iter = rhs.begin(); - iter != rhs.end(); - ++iter - ) + forAllConstIter(IDLList, rhs, iter) { add(iter().clone(*this).ptr()); } @@ -904,12 +872,7 @@ void Foam::dictionary::operator+=(const dictionary& rhs) << abort(FatalError); } - for - ( - IDLList::const_iterator iter = rhs.begin(); - iter != rhs.end(); - ++iter - ) + forAllConstIter(IDLList, rhs, iter) { add(iter().clone(*this).ptr()); } @@ -926,12 +889,7 @@ void Foam::dictionary::operator|=(const dictionary& rhs) << abort(FatalError); } - for - ( - IDLList::const_iterator iter = rhs.begin(); - iter != rhs.end(); - ++iter - ) + forAllConstIter(IDLList, rhs, iter) { if (!found(iter().keyword())) { @@ -951,12 +909,7 @@ void Foam::dictionary::operator<<=(const dictionary& rhs) << abort(FatalError); } - for - ( - IDLList::const_iterator iter = rhs.begin(); - iter != rhs.end(); - ++iter - ) + forAllConstIter(IDLList, rhs, iter) { set(iter().clone(*this).ptr()); } diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C index 2f0987d16b..96196e3a11 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryIO.C +++ b/src/OpenFOAM/db/dictionary/dictionaryIO.C @@ -154,12 +154,8 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const // Write entry os << e; - // Add new line if applicable - if - ( - (e.isDict() || (!e.isDict() && parent()==dictionary::null)) - && e != *last() - ) + // Add extra new line between entries for "top-level" dictionaries + if (!subDict && parent() == dictionary::null && e != *last()) { os << nl; } @@ -167,7 +163,7 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const // Check stream before going to next entry. if (!os.good()) { - WarningIn("dictionary::write(Ostream& os, bool subDict)") + WarningIn("dictionary::write(Ostream&, bool subDict)") << "Can't write entry " << iter().keyword() << " for dictionary " << name() << endl; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C index 601674ac7e..e36de4108c 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C @@ -103,14 +103,13 @@ bool Foam::functionEntry::execute is.fatalCheck ( "functionEntry::execute" - "(const word& functionName, const dictionary& parentDict, " - "primitiveEntry&, Istream&)" + "(const word&, const dictionary&, primitiveEntry&, Istream&)" ); if (!executeprimitiveEntryIstreamMemberFunctionTablePtr_) { cerr<<"functionEntry::execute" - << "(const word&, dictionary&, primitiveEntry&, Istream&)" + << "(const word&, const dictionary&, primitiveEntry&, Istream&)" << " not yet initialized, function = " << functionName.c_str() << std::endl; @@ -126,8 +125,7 @@ bool Foam::functionEntry::execute FatalErrorIn ( "functionEntry::execute" - "(const word& functionName, const dictionary& parentDict, " - "primitiveEntry&, Istream&)" + "(const word&, const dictionary&, primitiveEntry&, Istream&)" ) << "Unknown functionEntry " << functionName << endl << endl << "Valid functionEntries are :" << endl diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H index f4d1702b4f..ebfd49470b 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H @@ -95,7 +95,7 @@ public: ( const word& functionName, dictionary& parentDict, - Istream& is + Istream& ); declareMemberFunctionSelectionTable @@ -117,8 +117,8 @@ public: ( const word& functionName, const dictionary& parentDict, - primitiveEntry& entry, - Istream& is + primitiveEntry&, + Istream& ); diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C index e9f11d56a5..7879369017 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C @@ -62,8 +62,7 @@ namespace functionEntries } } - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // Foam::fileName Foam::functionEntries::includeEntry::includeFileName ( @@ -73,6 +72,7 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName fileName fName(is); fName.expand(); + // relative name if (fName.size() && fName[0] != '/') { fName = fileName(is.name()).path()/fName; @@ -82,17 +82,19 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName } +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + bool Foam::functionEntries::includeEntry::execute ( dictionary& parentDict, Istream& is ) { - IFstream fileStream(includeFileName(is)); + IFstream ifs(includeFileName(is)); - if (fileStream) + if (ifs) { - parentDict.read(fileStream); + parentDict.read(ifs); return true; } else @@ -100,9 +102,9 @@ bool Foam::functionEntries::includeEntry::execute FatalIOErrorIn ( "functionEntries::includeEntry::includeEntry" - "(dictionary& parentDict,Istream& is)", + "(dictionary& parentDict, Istream&)", is - ) << "Cannot open include file " << fileStream.name() + ) << "Cannot open include file " << ifs.name() << " while reading dictionary " << parentDict.name() << exit(FatalIOError); @@ -117,11 +119,11 @@ bool Foam::functionEntries::includeEntry::execute Istream& is ) { - IFstream fileStream(includeFileName(is)); + IFstream ifs(includeFileName(is)); - if (fileStream) + if (ifs) { - entry.read(parentDict, fileStream); + entry.read(parentDict, ifs); return true; } else @@ -129,9 +131,9 @@ bool Foam::functionEntries::includeEntry::execute FatalIOErrorIn ( "functionEntries::includeEntry::includeEntry" - "(dictionary& parentDict, primitiveEntry& entry, Istream& is)", + "(dictionary& parentDict, primitiveEntry& entry, Istream&)", is - ) << "Cannot open include file " << fileStream.name() + ) << "Cannot open include file " << ifs.name() << " while reading dictionary " << parentDict.name() << exit(FatalIOError); diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H index effff83a31..b260e3f36c 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H @@ -58,7 +58,7 @@ namespace functionEntries { /*---------------------------------------------------------------------------*\ - Class includeEntry Declaration + Class includeEntry Declaration \*---------------------------------------------------------------------------*/ class includeEntry @@ -68,7 +68,7 @@ class includeEntry // Private Member Functions //- Read the include fileName from Istream, expand and return - static fileName includeFileName(Istream& is); + static fileName includeFileName(Istream&); //- Disallow default bitwise copy construct includeEntry(const includeEntry&); @@ -86,18 +86,14 @@ public: // Member Functions //- Execute the functionEntry in a sub-dict context - static bool execute - ( - dictionary& parentDict, - Istream& is - ); + static bool execute(dictionary& parentDict, Istream&); //- Execute the functionEntry in a primitiveEntry context static bool execute ( const dictionary& parentDict, - primitiveEntry& entry, - Istream& is + primitiveEntry&, + Istream& ); }; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C index 60c348e244..f711da80aa 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C @@ -39,6 +39,9 @@ const Foam::word Foam::functionEntries::inputModeEntry::typeName // might include inputModeEntries int Foam::functionEntries::inputModeEntry::debug(0); +Foam::functionEntries::inputModeEntry::inputMode + Foam::functionEntries::inputModeEntry::mode_(MERGE); + namespace Foam { namespace functionEntries @@ -53,10 +56,6 @@ namespace functionEntries } } -// * * * * * * * * * * * * * * * * Private Data * * * * * * * * * * * * * * // - -Foam::label Foam::functionEntries::inputModeEntry::mode_ = imError; - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // we could combine this into execute() directly, but leave it here for now @@ -65,17 +64,17 @@ void Foam::functionEntries::inputModeEntry::setMode(Istream& is) clear(); word mode(is); - if (mode == "merge") + if (mode == "merge" || mode == "default") { - mode_ = imMerge; + mode_ = MERGE; } else if (mode == "overwrite") { - mode_ = imOverwrite; + mode_ = OVERWRITE; } - else if (mode == "error" || mode == "default") + else if (mode == "error") { - mode_ = imError; + mode_ = ERROR; } else { @@ -101,33 +100,19 @@ bool Foam::functionEntries::inputModeEntry::execute void Foam::functionEntries::inputModeEntry::clear() { - mode_ = imError; + mode_ = MERGE; } bool Foam::functionEntries::inputModeEntry::merge() { - if (mode_ & imMerge) - { - return true; - } - else - { - return false; - } + return mode_ == MERGE; } bool Foam::functionEntries::inputModeEntry::overwrite() { - if (mode_ & imOverwrite) - { - return true; - } - else - { - return false; - } + return mode_ == OVERWRITE; } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H index 394ad15779..9ecb558da9 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H @@ -38,7 +38,7 @@ Description @param merge merge sub-dictionaries when possible @param overwrite keep last entry and silently remove previous ones @param error flag duplicate entry as an error - @param default currently the same as error + @param default currently the same as merge SourceFiles inputModeEntry.C @@ -68,13 +68,13 @@ class inputModeEntry //- input mode options enum inputMode { - imError = 0, - imMerge = 0x1, - imOverwrite = 0x2 + ERROR, + MERGE, + OVERWRITE }; //- current input mode - static label mode_; + static inputMode mode_; // Private Member Functions @@ -98,19 +98,15 @@ public: // Member Functions //- Execute the functionEntry in a sub-dict context - static bool execute - ( - dictionary& parentDict, - Istream& - ); + static bool execute(dictionary& parentDict, Istream&); - //- Reset the inputMode to 'default' + //- Reset the inputMode to %default static void clear(); - //- Return true if the inputMode is 'merge' + //- Return true if the inputMode is %merge static bool merge(); - //- Return true if the inputMode is 'overwrite' + //- Return true if the inputMode is %overwrite static bool overwrite(); }; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H index 443d28889f..1ed2d99639 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H @@ -80,11 +80,7 @@ public: // Member Functions //- Execute the functionEntry in a sub-dict context - static bool execute - ( - dictionary& parentDict, - Istream& is - ); + static bool execute(dictionary& parentDict, Istream&); }; diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C index 8672f32753..8c37d28b42 100644 --- a/src/OpenFOAM/matrices/solution/solution.C +++ b/src/OpenFOAM/matrices/solution/solution.C @@ -162,10 +162,7 @@ bool Foam::solution::read() relaxationFactors_ = dict.subDict("relaxationFactors"); } - if (relaxationFactors_.found("default")) - { - relaxationFactors_.lookup("default") >> defaultRelaxationFactor_; - } + relaxationFactors_.readIfPresent("default", defaultRelaxationFactor_); if (dict.found("solvers")) { @@ -227,7 +224,7 @@ Foam::scalar Foam::solution::relaxationFactor(const word& name) const { FatalIOErrorIn ( - "Foam::solution::relaxationFactor(const word& name)", + "Foam::solution::relaxationFactor(const word&)", relaxationFactors_ ) << "Cannot find relaxationFactor for '" << name << "' or a suitable default value." @@ -242,7 +239,7 @@ const Foam::dictionary& Foam::solution::solverDict(const word& name) const { if (debug) { - InfoIn("solution::solverDict(const word& name)") + InfoIn("solution::solverDict(const word&)") << "Lookup solver for " << name << endl; } @@ -254,7 +251,7 @@ const Foam::dictionary& Foam::solution::solver(const word& name) const { if (debug) { - InfoIn("solution::solver(const word& name)") + InfoIn("solution::solver(const word&)") << "Lookup solver for " << name << endl; }