mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: rationalize dictionary access methods
- use keyType::option enum to consolidate searching options.
These enumeration names should be more intuitive to use
and improve code readability.
Eg, lookupEntry(key, keyType::REGEX);
vs lookupEntry(key, false, true);
or
Eg, lookupEntry(key, keyType::LITERAL_RECURSIVE);
vs lookupEntry(key, true, false);
- new findEntry(), findDict(), findScoped() methods with consolidated
search options for shorter naming and access names more closely
aligned with other components. Behave simliarly to the
methods lookupEntryPtr(), subDictPtr(), lookupScopedEntryPtr(),
respectively. Default search parameters consistent with lookupEntry().
Eg, const entry* e = dict.findEntry(key);
vs const entry* e = dict.lookupEntryPtr(key, false, true);
- added '*' and '->' dereference operators to dictionary searchers.
This commit is contained in:
@ -82,8 +82,8 @@ int main(int argc, char *argv[])
|
||||
Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc()
|
||||
<< endl;
|
||||
|
||||
dictionary dict3(dict2.subDictPtr("boundaryField"));
|
||||
dictionary dict4(dict2.subDictPtr("NONEXISTENT"));
|
||||
dictionary dict3(dict2.findDict("boundaryField"));
|
||||
dictionary dict4(dict2.findDict("NONEXISTENT"));
|
||||
|
||||
Info<< "dictionary construct from pointer" << nl
|
||||
<< "ok = " << dict3.name() << " " << dict3.toc() << nl
|
||||
@ -105,23 +105,17 @@ int main(int argc, char *argv[])
|
||||
Info<< "Pattern find \"abc\" in top directory : "
|
||||
<< dict.lookup("abc") << endl;
|
||||
Info<< "Pattern find \"abc\" in sub directory : "
|
||||
<< dict.subDict("someDict").lookup("abc")
|
||||
<< endl;
|
||||
<< dict.subDict("someDict").lookup("abc") << nl;
|
||||
Info<< "Recursive pattern find \"def\" in sub directory : "
|
||||
<< dict.subDict("someDict").lookup("def", true)
|
||||
<< endl;
|
||||
<< dict.subDict("someDict").lookup("def", true) << nl;
|
||||
Info<< "Recursive pattern find \"foo\" in sub directory : "
|
||||
<< dict.subDict("someDict").lookup("foo", true)
|
||||
<< endl;
|
||||
<< dict.subDict("someDict").lookup("foo", true) << nl;
|
||||
Info<< "Recursive pattern find \"fooz\" in sub directory : "
|
||||
<< dict.subDict("someDict").lookup("fooz", true)
|
||||
<< endl;
|
||||
<< dict.subDict("someDict").lookup("fooz", true) << nl;
|
||||
Info<< "Recursive pattern find \"bar\" in sub directory : "
|
||||
<< dict.subDict("someDict").lookup("bar", true)
|
||||
<< endl;
|
||||
<< dict.subDict("someDict").lookup("bar", true) << nl;
|
||||
Info<< "Recursive pattern find \"xxx\" in sub directory : "
|
||||
<< dict.subDict("someDict").lookup("xxx", true)
|
||||
<< endl;
|
||||
<< dict.subDict("someDict").lookup("xxx", true) << nl;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -52,20 +52,16 @@ bool checkDictionaryContent(const dictionary& dict1, const dictionary& dict2)
|
||||
|
||||
forAllConstIter(dictionary, dict1, iter1)
|
||||
{
|
||||
const entry* entryPtr = dict2.lookupEntryPtr
|
||||
(
|
||||
iter1().keyword(),
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry* eptr =
|
||||
dict2.findEntry(iter1().keyword(), keyType::LITERAL);
|
||||
|
||||
if (!entryPtr)
|
||||
if (!eptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const entry& entry1 = iter1();
|
||||
const entry& entry2 = *entryPtr;
|
||||
const entry& entry2 = *eptr;
|
||||
|
||||
bool ok = false;
|
||||
if (entry1.isDict())
|
||||
|
||||
@ -63,9 +63,13 @@ Foam::cellSizeFunction::cellSizeFunction
|
||||
defaultCellSize_(defaultCellSize),
|
||||
regionIndices_(regionIndices),
|
||||
sideMode_(),
|
||||
priority_(cellSizeFunctionDict.get<label>("priority", true))
|
||||
priority_
|
||||
(
|
||||
cellSizeFunctionDict.get<label>("priority", keyType::REGEX_RECURSIVE)
|
||||
)
|
||||
{
|
||||
const word mode = cellSizeFunctionDict.get<word>("mode", true);
|
||||
const word mode =
|
||||
cellSizeFunctionDict.get<word>("mode", keyType::REGEX_RECURSIVE);
|
||||
|
||||
if (surface_.hasVolumeType())
|
||||
{
|
||||
|
||||
@ -837,7 +837,7 @@ void Foam::conformalVoronoiMesh::checkCellSizing()
|
||||
= dict.subDict("meshQualityControls");
|
||||
|
||||
const scalar maxNonOrtho =
|
||||
meshQualityDict.get<scalar>("maxNonOrtho", true);
|
||||
meshQualityDict.get<scalar>("maxNonOrtho", keyType::REGEX_RECURSIVE);
|
||||
|
||||
label nWrongFaces = 0;
|
||||
|
||||
|
||||
@ -339,7 +339,7 @@ Foam::conformationSurfaces::conformationSurfaces
|
||||
{
|
||||
const word& geomName = allGeometry_.names()[geomI];
|
||||
|
||||
const entry* ePtr = surfacesDict.lookupEntryPtr(geomName, false, true);
|
||||
const entry* ePtr = surfacesDict.findEntry(geomName, keyType::REGEX);
|
||||
|
||||
if (ePtr)
|
||||
{
|
||||
|
||||
@ -125,7 +125,7 @@ autoPtr<refinementSurfaces> createRefinementSurfaces
|
||||
{
|
||||
const word& geomName = allGeometry.names()[geomi];
|
||||
|
||||
const entry* ePtr = surfacesDict.lookupEntryPtr(geomName, false, true);
|
||||
const entry* ePtr = surfacesDict.findEntry(geomName, keyType::REGEX);
|
||||
|
||||
if (ePtr)
|
||||
{
|
||||
|
||||
@ -170,9 +170,10 @@ class dictAndKeyword
|
||||
word key_;
|
||||
|
||||
public:
|
||||
|
||||
dictAndKeyword(const word& scopedName)
|
||||
{
|
||||
string::size_type i = scopedName.rfind('/');
|
||||
auto i = scopedName.rfind('/');
|
||||
if (i == string::npos)
|
||||
{
|
||||
i = scopedName.rfind('.');
|
||||
@ -212,7 +213,7 @@ const dictionary& lookupScopedDict
|
||||
return dict;
|
||||
}
|
||||
|
||||
const entry* eptr = dict.lookupScopedEntryPtr(subDictName, false, false);
|
||||
const entry* eptr = dict.findScoped(subDictName, keyType::LITERAL);
|
||||
|
||||
if (!eptr || !eptr->isDict())
|
||||
{
|
||||
@ -231,7 +232,7 @@ void removeDict(dictionary& dict, const dictionary& dictToRemove)
|
||||
{
|
||||
for (const entry& refEntry : dictToRemove)
|
||||
{
|
||||
auto finder = dict.search(refEntry.keyword(), false, false);
|
||||
auto finder = dict.search(refEntry.keyword(), keyType::LITERAL);
|
||||
|
||||
bool purge = false;
|
||||
|
||||
@ -357,8 +358,7 @@ int main(int argc, char *argv[])
|
||||
bool changed = false;
|
||||
|
||||
// Read but preserve headers
|
||||
dictionary dict;
|
||||
dict.read(dictFile(), true);
|
||||
dictionary dict(dictFile(), true);
|
||||
|
||||
if (listIncludes)
|
||||
{
|
||||
@ -455,12 +455,7 @@ int main(int argc, char *argv[])
|
||||
changed = true;
|
||||
|
||||
// Print the changed entry
|
||||
const auto finder = dict.csearchScoped
|
||||
(
|
||||
scopedName,
|
||||
false,
|
||||
true // Support wildcards
|
||||
);
|
||||
const auto finder = dict.csearchScoped(scopedName, keyType::REGEX);
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -489,8 +484,8 @@ int main(int argc, char *argv[])
|
||||
const dictionary& d1(lookupScopedDict(dict, dAk.dict()));
|
||||
const dictionary& d2(lookupScopedDict(diffDict, dAk.dict()));
|
||||
|
||||
const entry* e1Ptr = d1.lookupEntryPtr(dAk.key(), false, true);
|
||||
const entry* e2Ptr = d2.lookupEntryPtr(dAk.key(), false, true);
|
||||
const entry* e1Ptr = d1.findEntry(dAk.key(), keyType::REGEX);
|
||||
const entry* e2Ptr = d2.findEntry(dAk.key(), keyType::REGEX);
|
||||
|
||||
if (e1Ptr && e2Ptr)
|
||||
{
|
||||
@ -509,12 +504,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
const auto finder = dict.csearchScoped
|
||||
(
|
||||
scopedName,
|
||||
false,
|
||||
true // Support wildcards
|
||||
);
|
||||
const auto finder = dict.csearchScoped(scopedName, keyType::REGEX);
|
||||
|
||||
if (!finder.found())
|
||||
{
|
||||
|
||||
@ -183,7 +183,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Assumed to be good if it has 'profiling' sub-dict
|
||||
|
||||
const dictionary* ptr = dict.subDictPtr(blockNameProfiling);
|
||||
const dictionary* ptr = dict.findDict(blockNameProfiling);
|
||||
if (ptr)
|
||||
{
|
||||
++nDict;
|
||||
@ -295,13 +295,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (const dictionary& procDict : profiles)
|
||||
{
|
||||
const dictionary* inDictPtr =
|
||||
procDict.subDictPtr(level1Name);
|
||||
const dictionary* inDictPtr = procDict.findDict(level1Name);
|
||||
|
||||
if (inDictPtr && hasDictEntries)
|
||||
{
|
||||
// descend to the next level as required
|
||||
inDictPtr = inDictPtr->subDictPtr(level2Name);
|
||||
// Descend to the next level as required
|
||||
inDictPtr = inDictPtr->findDict(level2Name);
|
||||
}
|
||||
|
||||
if (!inDictPtr)
|
||||
@ -313,16 +312,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (const word& tag : tags)
|
||||
{
|
||||
const entry* eptr = inDictPtr->lookupEntryPtr
|
||||
(
|
||||
tag,
|
||||
false,
|
||||
false
|
||||
);
|
||||
scalar val;
|
||||
|
||||
if (eptr)
|
||||
if
|
||||
(
|
||||
inDictPtr->readIfPresent(tag, val, keyType::LITERAL)
|
||||
)
|
||||
{
|
||||
const scalar val = readScalar(eptr->stream());
|
||||
stats(tag).append(val);
|
||||
}
|
||||
}
|
||||
@ -339,7 +335,7 @@ int main(int argc, char *argv[])
|
||||
if (hasDictEntries)
|
||||
{
|
||||
outputDict.add(level2Name, level1Dict.subDict(level2Name));
|
||||
outDictPtr = outputDict.subDictPtr(level2Name);
|
||||
outDictPtr = outputDict.findDict(level2Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -235,10 +235,9 @@ bool merge
|
||||
// Save current (non-wildcard) keys before adding items.
|
||||
wordHashSet thisKeysSet;
|
||||
{
|
||||
List<keyType> keys = thisDict.keys(false);
|
||||
forAll(keys, i)
|
||||
for (const word& k : thisDict.keys(false))
|
||||
{
|
||||
thisKeysSet.insert(keys[i]);
|
||||
thisKeysSet.insert(k);
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,25 +260,20 @@ bool merge
|
||||
}
|
||||
else if (literalRE || !(key.isPattern() || shortcuts.found(key)))
|
||||
{
|
||||
entry* entryPtr = thisDict.lookupEntryPtr
|
||||
(
|
||||
key,
|
||||
false, // recursive
|
||||
false // patternMatch
|
||||
);
|
||||
entry* eptr = thisDict.findEntry(key, keyType::LITERAL);
|
||||
|
||||
if (entryPtr)
|
||||
if (eptr)
|
||||
{
|
||||
// Mark thisDict entry as having been match for wildcard
|
||||
// handling later on.
|
||||
thisKeysSet.erase(entryPtr->keyword());
|
||||
thisKeysSet.erase(eptr->keyword());
|
||||
|
||||
if
|
||||
(
|
||||
addEntry
|
||||
(
|
||||
thisDict,
|
||||
*entryPtr,
|
||||
*eptr,
|
||||
mergeIter(),
|
||||
literalRE,
|
||||
shortcuts
|
||||
@ -310,7 +304,7 @@ bool merge
|
||||
|
||||
// Pass 2. Wildcard or shortcut matches (if any) on any non-match keys.
|
||||
|
||||
if (!literalRE && thisKeysSet.size() > 0)
|
||||
if (!literalRE && thisKeysSet.size())
|
||||
{
|
||||
// Pick up remaining dictionary entries
|
||||
wordList thisKeys(thisKeysSet.toc());
|
||||
@ -336,10 +330,10 @@ bool merge
|
||||
);
|
||||
|
||||
// Remove all matches
|
||||
forAll(matches, i)
|
||||
for (const label matchi : matches)
|
||||
{
|
||||
const word& thisKey = thisKeys[matches[i]];
|
||||
thisKeysSet.erase(thisKey);
|
||||
const word& k = thisKeys[matchi];
|
||||
thisKeysSet.erase(k);
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
@ -358,21 +352,18 @@ bool merge
|
||||
);
|
||||
|
||||
// Add all matches
|
||||
forAll(matches, i)
|
||||
for (const label matchi : matches)
|
||||
{
|
||||
const word& thisKey = thisKeys[matches[i]];
|
||||
const word& k = thisKeys[matchi];
|
||||
|
||||
entry& thisEntry = const_cast<entry&>
|
||||
(
|
||||
thisDict.lookupEntry(thisKey, false, false)
|
||||
);
|
||||
entry* eptr = thisDict.findEntry(k, keyType::LITERAL);
|
||||
|
||||
if
|
||||
(
|
||||
addEntry
|
||||
(
|
||||
thisDict,
|
||||
thisEntry,
|
||||
*eptr,
|
||||
mergeIter(),
|
||||
literalRE,
|
||||
HashTable<wordList>(0) // no shortcuts
|
||||
@ -627,8 +618,7 @@ int main(int argc, char *argv[])
|
||||
fieldDict.lookupEntry
|
||||
(
|
||||
doneKeys[i],
|
||||
false,
|
||||
true
|
||||
keyType::REGEX
|
||||
).clone()
|
||||
);
|
||||
fieldDict.remove(doneKeys[i]);
|
||||
|
||||
@ -342,11 +342,11 @@ void Foam::Time::setControls()
|
||||
|
||||
void Foam::Time::setMonitoring(const bool forceProfiling)
|
||||
{
|
||||
const dictionary* profilingDict = controlDict_.subDictPtr("profiling");
|
||||
const dictionary* profilingDict = controlDict_.findDict("profiling");
|
||||
if (!profilingDict)
|
||||
{
|
||||
// ... or from etc/controlDict
|
||||
profilingDict = debug::controlDict().subDictPtr("profiling");
|
||||
profilingDict = debug::controlDict().findDict("profiling");
|
||||
}
|
||||
|
||||
// initialize profiling on request
|
||||
|
||||
@ -99,7 +99,7 @@ void Foam::Time::readDict()
|
||||
// DebugSwitches
|
||||
if
|
||||
(
|
||||
(localDict = controlDict_.subDictPtr("DebugSwitches")) != nullptr
|
||||
(localDict = controlDict_.findDict("DebugSwitches")) != nullptr
|
||||
&& localDict->size()
|
||||
)
|
||||
{
|
||||
@ -146,7 +146,7 @@ void Foam::Time::readDict()
|
||||
// InfoSwitches
|
||||
if
|
||||
(
|
||||
(localDict = controlDict_.subDictPtr("InfoSwitches")) != nullptr
|
||||
(localDict = controlDict_.findDict("InfoSwitches")) != nullptr
|
||||
&& localDict->size()
|
||||
)
|
||||
{
|
||||
@ -192,7 +192,7 @@ void Foam::Time::readDict()
|
||||
// OptimisationSwitches
|
||||
if
|
||||
(
|
||||
(localDict = controlDict_.subDictPtr("OptimisationSwitches")) != nullptr
|
||||
(localDict = controlDict_.findDict("OptimisationSwitches")) != nullptr
|
||||
&& localDict->size()
|
||||
)
|
||||
{
|
||||
@ -273,7 +273,7 @@ void Foam::Time::readDict()
|
||||
if
|
||||
(
|
||||
|
||||
(localDict = controlDict_.subDictPtr("DimensionedConstants")) != nullptr
|
||||
(localDict = controlDict_.findDict("DimensionedConstants")) != nullptr
|
||||
&& localDict->size()
|
||||
)
|
||||
{
|
||||
@ -310,7 +310,7 @@ void Foam::Time::readDict()
|
||||
// DimensionSets
|
||||
if
|
||||
(
|
||||
(localDict = controlDict_.subDictPtr("DimensionSets")) != nullptr
|
||||
(localDict = controlDict_.findDict("DimensionSets")) != nullptr
|
||||
&& localDict->size()
|
||||
)
|
||||
{
|
||||
|
||||
@ -134,13 +134,14 @@ void Foam::dictionary::checkITstream
|
||||
|
||||
Foam::dictionary::dictionary()
|
||||
:
|
||||
name_(),
|
||||
parent_(dictionary::null)
|
||||
{}
|
||||
|
||||
|
||||
Foam::dictionary::dictionary(const fileName& name)
|
||||
:
|
||||
dictionaryName(name),
|
||||
name_(name),
|
||||
parent_(dictionary::null)
|
||||
{}
|
||||
|
||||
@ -151,8 +152,8 @@ Foam::dictionary::dictionary
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
dictionaryName(dict.name()),
|
||||
parent_type(dict, *this),
|
||||
name_(dict.name()),
|
||||
parent_(parentDict)
|
||||
{
|
||||
forAllIter(parent_type, *this, iter)
|
||||
@ -173,8 +174,8 @@ Foam::dictionary::dictionary
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
dictionaryName(dict.name()),
|
||||
parent_type(dict, *this),
|
||||
name_(dict.name()),
|
||||
parent_(dictionary::null)
|
||||
{
|
||||
forAllIter(parent_type, *this, iter)
|
||||
@ -190,16 +191,14 @@ Foam::dictionary::dictionary
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary::dictionary
|
||||
(
|
||||
const dictionary* dictPtr
|
||||
)
|
||||
Foam::dictionary::dictionary(const dictionary* dict)
|
||||
:
|
||||
name_(),
|
||||
parent_(dictionary::null)
|
||||
{
|
||||
if (dictPtr)
|
||||
if (dict)
|
||||
{
|
||||
operator=(*dictPtr);
|
||||
operator=(*dict);
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,6 +209,7 @@ Foam::dictionary::dictionary
|
||||
dictionary&& dict
|
||||
)
|
||||
:
|
||||
name_(),
|
||||
parent_(parentDict)
|
||||
{
|
||||
transfer(dict);
|
||||
@ -222,6 +222,7 @@ Foam::dictionary::dictionary
|
||||
dictionary&& dict
|
||||
)
|
||||
:
|
||||
name_(),
|
||||
parent_(dictionary::null)
|
||||
{
|
||||
transfer(dict);
|
||||
@ -310,44 +311,50 @@ Foam::tokenList Foam::dictionary::tokens() const
|
||||
bool Foam::dictionary::found
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return csearch(keyword, recursive, patternMatch).found();
|
||||
return csearch(keyword, matchOpt).found();
|
||||
}
|
||||
|
||||
|
||||
const Foam::entry* Foam::dictionary::lookupEntryPtr
|
||||
Foam::entry* Foam::dictionary::findEntry
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
return csearch(keyword, recursive, patternMatch).ptr();
|
||||
}
|
||||
|
||||
|
||||
Foam::entry* Foam::dictionary::lookupEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
)
|
||||
{
|
||||
return search(keyword, recursive, patternMatch).ptr();
|
||||
return search(keyword, matchOpt).ptr();
|
||||
}
|
||||
|
||||
|
||||
const Foam::entry* Foam::dictionary::findEntry
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return csearch(keyword, matchOpt).ptr();
|
||||
}
|
||||
|
||||
|
||||
const Foam::entry* Foam::dictionary::findScoped
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return csearchScoped(keyword, matchOpt).ptr();
|
||||
}
|
||||
|
||||
|
||||
const Foam::entry& Foam::dictionary::lookupEntry
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
const const_searcher finder(csearch(keyword, recursive, patternMatch));
|
||||
const const_searcher finder(csearch(keyword, matchOpt));
|
||||
|
||||
if (!finder.found())
|
||||
{
|
||||
@ -364,22 +371,10 @@ const Foam::entry& Foam::dictionary::lookupEntry
|
||||
Foam::ITstream& Foam::dictionary::lookup
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return lookupEntry(keyword, recursive, patternMatch).stream();
|
||||
}
|
||||
|
||||
|
||||
const Foam::entry* Foam::dictionary::lookupScopedEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
return csearchScoped(keyword, recursive, patternMatch).ptr();
|
||||
return lookupEntry(keyword, matchOpt).stream();
|
||||
}
|
||||
|
||||
|
||||
@ -394,7 +389,7 @@ bool Foam::dictionary::substituteKeyword(const word& keyword, bool mergeEntry)
|
||||
const word varName(keyword.substr(1), false);
|
||||
|
||||
// Lookup the variable name in the given dictionary
|
||||
const const_searcher finder(csearch(varName, true, true));
|
||||
const const_searcher finder(csearch(varName, keyType::REGEX_RECURSIVE));
|
||||
|
||||
// If defined insert its entries into this dictionary
|
||||
if (finder.found())
|
||||
@ -428,7 +423,7 @@ bool Foam::dictionary::substituteScopedKeyword
|
||||
const word varName(keyword.substr(1), false);
|
||||
|
||||
// Lookup the variable name in the given dictionary
|
||||
const const_searcher finder(csearchScoped(varName, true, true));
|
||||
const auto finder(csearchScoped(varName, keyType::REGEX_RECURSIVE));
|
||||
|
||||
// If defined insert its entries into this dictionary
|
||||
if (finder.found())
|
||||
@ -449,29 +444,35 @@ bool Foam::dictionary::substituteScopedKeyword
|
||||
|
||||
bool Foam::dictionary::isDict(const word& keyword) const
|
||||
{
|
||||
// Find non-recursive with patterns
|
||||
return csearch(keyword, false, true).isDict();
|
||||
// Allow patterns, non-recursive
|
||||
return csearch(keyword, keyType::REGEX).isDict();
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const
|
||||
Foam::dictionary* Foam::dictionary::findDict
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt
|
||||
)
|
||||
{
|
||||
// Find non-recursive with patterns
|
||||
return csearch(keyword, false, true).dictPtr();
|
||||
return search(keyword, matchOpt).dictPtr();
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword)
|
||||
const Foam::dictionary* Foam::dictionary::findDict
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
// Find non-recursive with patterns
|
||||
return search(keyword, false, true).dictPtr();
|
||||
return csearch(keyword, matchOpt).dictPtr();
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
|
||||
{
|
||||
// Find non-recursive with patterns
|
||||
const const_searcher finder(csearch(keyword, false, true));
|
||||
// Allow patterns, non-recursive
|
||||
const const_searcher finder(csearch(keyword, keyType::REGEX));
|
||||
|
||||
if (!finder.found())
|
||||
{
|
||||
@ -487,8 +488,8 @@ const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
|
||||
|
||||
Foam::dictionary& Foam::dictionary::subDict(const word& keyword)
|
||||
{
|
||||
// Find non-recursive with patterns
|
||||
searcher finder = search(keyword, false, true);
|
||||
// Allow patterns, non-recursive
|
||||
searcher finder(search(keyword, keyType::REGEX));
|
||||
|
||||
if (!finder.found())
|
||||
{
|
||||
@ -508,8 +509,8 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict
|
||||
const bool mandatory
|
||||
) const
|
||||
{
|
||||
// Find non-recursive with patterns
|
||||
const const_searcher finder(csearch(keyword, false, true));
|
||||
// Allow patterns, non-recursive
|
||||
const const_searcher finder(csearch(keyword, keyType::REGEX));
|
||||
|
||||
if (finder.isDict())
|
||||
{
|
||||
@ -543,7 +544,8 @@ const Foam::dictionary& Foam::dictionary::optionalSubDict
|
||||
const word& keyword
|
||||
) const
|
||||
{
|
||||
const const_searcher finder(csearch(keyword, false, true));
|
||||
// Allow patterns, non-recursive
|
||||
const const_searcher finder(csearch(keyword, keyType::REGEX));
|
||||
|
||||
if (finder.isDict())
|
||||
{
|
||||
@ -565,15 +567,15 @@ const Foam::dictionary& Foam::dictionary::optionalSubDict
|
||||
|
||||
Foam::wordList Foam::dictionary::toc() const
|
||||
{
|
||||
wordList keys(size());
|
||||
wordList list(size());
|
||||
|
||||
label n = 0;
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
keys[n++] = iter().keyword();
|
||||
list[n++] = iter().keyword();
|
||||
}
|
||||
|
||||
return keys;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@ -585,19 +587,19 @@ Foam::wordList Foam::dictionary::sortedToc() const
|
||||
|
||||
Foam::List<Foam::keyType> Foam::dictionary::keys(bool patterns) const
|
||||
{
|
||||
List<keyType> keys(size());
|
||||
List<keyType> list(size());
|
||||
|
||||
label n = 0;
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
if (iter().keyword().isPattern() ? patterns : !patterns)
|
||||
{
|
||||
keys[n++] = iter().keyword();
|
||||
list[n++] = iter().keyword();
|
||||
}
|
||||
}
|
||||
keys.setSize(n);
|
||||
list.resize(n);
|
||||
|
||||
return keys;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@ -746,7 +748,7 @@ Foam::entry* Foam::dictionary::set(entry* entryPtr)
|
||||
}
|
||||
|
||||
// Find non-recursive with patterns
|
||||
searcher finder(search(entryPtr->keyword(), false, true));
|
||||
searcher finder(search(entryPtr->keyword(), keyType::REGEX));
|
||||
|
||||
// Clear dictionary so merge acts like overwrite
|
||||
if (finder.isDict())
|
||||
|
||||
@ -112,70 +112,12 @@ class SHA1Digest;
|
||||
Istream& operator>>(Istream& is, dictionary& dict);
|
||||
Ostream& operator<<(Ostream& os, const dictionary& dict);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class dictionaryName Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Holds name for a dictionary
|
||||
class dictionaryName
|
||||
{
|
||||
// Private data
|
||||
|
||||
fileName name_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
dictionaryName()
|
||||
{}
|
||||
|
||||
//- Construct as copy of the given fileName
|
||||
dictionaryName(const fileName& name)
|
||||
:
|
||||
name_(name)
|
||||
{}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return the dictionary name
|
||||
const fileName& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Return the dictionary name for modification (use with caution).
|
||||
fileName& name()
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Return the local dictionary name (final part of scoped name)
|
||||
word dictName() const
|
||||
{
|
||||
word scopedName(name_.name());
|
||||
|
||||
const auto i = scopedName.rfind('.');
|
||||
if (i == std::string::npos)
|
||||
{
|
||||
return scopedName;
|
||||
}
|
||||
|
||||
return scopedName.substr(i+1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class dictionary Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class dictionary
|
||||
:
|
||||
public dictionaryName,
|
||||
public IDLList<entry>
|
||||
{
|
||||
public:
|
||||
@ -250,7 +192,7 @@ public:
|
||||
{}
|
||||
|
||||
|
||||
//- Entry was found.
|
||||
//- True if entry was found
|
||||
inline bool found() const
|
||||
{
|
||||
return eptr_;
|
||||
@ -298,6 +240,18 @@ public:
|
||||
{
|
||||
return *reinterpret_cast<const Searcher<!Const>*>(this);
|
||||
}
|
||||
|
||||
//- A pointer to the entry (nullptr if not found)
|
||||
pointer operator->() const
|
||||
{
|
||||
return eptr_;
|
||||
}
|
||||
|
||||
//- A reference to the entry (Error if not found)
|
||||
reference operator*() const
|
||||
{
|
||||
return *eptr_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -326,6 +280,9 @@ private:
|
||||
// Set/unset via an InfoSwitch
|
||||
static bool writeOptionalEntries;
|
||||
|
||||
//- The dictionary name
|
||||
fileName name_;
|
||||
|
||||
//- Parent dictionary
|
||||
const dictionary& parent_;
|
||||
|
||||
@ -353,6 +310,21 @@ private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Convert old-style (1806) boolean search specification to enum
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param pattern match using regular expressions as well
|
||||
static inline enum keyType::option
|
||||
matchOpt(bool recursive, bool pattern)
|
||||
{
|
||||
return
|
||||
keyType::option
|
||||
(
|
||||
(pattern ? keyType::REGEX : keyType::LITERAL)
|
||||
| (recursive ? keyType::RECURSIVE : 0)
|
||||
);
|
||||
}
|
||||
|
||||
//- Search using a '.' for scoping.
|
||||
// A leading dot means to use the parent dictionary.
|
||||
// An intermediate dot separates a sub-dictionary or sub-entry.
|
||||
@ -363,13 +335,11 @@ private:
|
||||
// The heuristic tries successively longer top-level entries
|
||||
// until there is a suitable match.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the search mode
|
||||
const_searcher csearchDotScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const;
|
||||
|
||||
//- Search using a '/' for scoping.
|
||||
@ -379,11 +349,11 @@ private:
|
||||
// ambiguity between separator and content.
|
||||
// No possibility or need for recursion.
|
||||
//
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the search mode. Recursive is ignored.
|
||||
const_searcher csearchSlashScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const;
|
||||
|
||||
|
||||
@ -411,16 +381,17 @@ public:
|
||||
explicit dictionary(const fileName& name);
|
||||
|
||||
//- Construct given the entry name, parent dictionary and Istream,
|
||||
//- reading entries until EOF
|
||||
//- reading entries until EOF, optionally keeping the header
|
||||
dictionary
|
||||
(
|
||||
const fileName& name,
|
||||
const dictionary& parentDict,
|
||||
Istream& is
|
||||
Istream& is,
|
||||
bool keepHeader = false
|
||||
);
|
||||
|
||||
//- Construct top-level dictionary from Istream,
|
||||
//- reading entries until EOF
|
||||
//- reading entries until EOF. Discards the header.
|
||||
dictionary(Istream& is);
|
||||
|
||||
//- Construct top-level dictionary from Istream,
|
||||
@ -435,7 +406,7 @@ public:
|
||||
|
||||
//- Construct top-level dictionary as copy from pointer to dictionary.
|
||||
// A null pointer is treated like an empty dictionary.
|
||||
dictionary(const dictionary* dictPtr);
|
||||
dictionary(const dictionary* dict);
|
||||
|
||||
//- Move construct for given parent dictionary
|
||||
dictionary(const dictionary& parentDict, dictionary&& dict);
|
||||
@ -458,6 +429,32 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- The dictionary name
|
||||
const fileName& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- The dictionary name for modification (use with caution).
|
||||
fileName& name()
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- The local dictionary name (final part of scoped name)
|
||||
word dictName() const
|
||||
{
|
||||
word scopedName(name_.name());
|
||||
|
||||
const auto i = scopedName.rfind('.');
|
||||
if (i == std::string::npos)
|
||||
{
|
||||
return scopedName;
|
||||
}
|
||||
|
||||
return scopedName.substr(i+1);
|
||||
}
|
||||
|
||||
//- Return the parent dictionary
|
||||
const dictionary& parent() const
|
||||
{
|
||||
@ -482,131 +479,137 @@ public:
|
||||
|
||||
// Search and lookup
|
||||
|
||||
//- Search dictionary for given keyword.
|
||||
// Default search: non-recursive with patterns.
|
||||
//- Search for an entry (const access) with the given keyword.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
//
|
||||
// \return True if entry was found
|
||||
bool found
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return an entry pointer if present, or return a nullptr.
|
||||
//- Find for an entry (non-const access) with the given keyword.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
const entry* lookupEntryPtr
|
||||
// \param matchOpt the search mode
|
||||
//
|
||||
// \return the entry pointer found or a nullptr.
|
||||
entry* findEntry
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const;
|
||||
|
||||
//- Find and return an entry pointer for manipulation if present,
|
||||
//- or return a nullptr.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
entry* lookupEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
);
|
||||
|
||||
//- Find and return an entry if present, otherwise FatalIOError.
|
||||
//- Find an entry (const access) with the given keyword.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
//
|
||||
// \return the entry pointer found or a nullptr.
|
||||
const entry* findEntry
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Search for a scoped entry (const access) with the given keyword.
|
||||
// Allows scoping using '.'.
|
||||
// Special handling for an absolute anchor (^) at start of the keyword
|
||||
// and for '..' to ascend into the parent dictionaries.
|
||||
//
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
//
|
||||
// \return the entry pointer found or a nullptr.
|
||||
const entry* findScoped
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return a sub-dictionary pointer if present
|
||||
// (and a sub-dictionary) otherwise return nullptr.
|
||||
//
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
dictionary* findDict
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
);
|
||||
|
||||
//- Search for an entry (const access) with the given keyword.
|
||||
//- Find and return a sub-dictionary pointer if present
|
||||
// (and a sub-dictionary) otherwise return nullptr.
|
||||
//
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
const dictionary* findDict
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
//
|
||||
// \return return an entry if present, otherwise FatalIOError.
|
||||
const entry& lookupEntry
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const;
|
||||
|
||||
//- Find and return a T.
|
||||
//- FatalIOError if not found, or if there are excess tokens.
|
||||
// Default search: non-recursive with patterns.
|
||||
//- FatalIOError if not found, or if the number of tokens is incorrect.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
template<class T>
|
||||
T get
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return an entry data stream.
|
||||
// Default search: non-recursive with patterns.
|
||||
//- FatalIOError if not found, or if the number of tokens is incorrect.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
ITstream& lookup
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return a T.
|
||||
//- FatalIOError if not found, or if there are excess tokens.
|
||||
// Default search: non-recursive with patterns.
|
||||
//- Find and return a T, or return the given default value.
|
||||
//- FatalIOError if it is found and the number of tokens is incorrect.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
//
|
||||
// \deprecated - same as the get() method
|
||||
template<class T>
|
||||
T lookupType
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
) const;
|
||||
|
||||
//- Find and return a T, or return the given default value
|
||||
//- FatalIOError if it is found and there are excess tokens.
|
||||
// Default search: non-recursive with patterns.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
template<class T>
|
||||
T lookupOrDefault
|
||||
(
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return a T, or return the given default value
|
||||
//- and add it to dictionary.
|
||||
//- FatalIOError if it is found and there are excess tokens.
|
||||
// Default search: non-recursive with patterns.
|
||||
//- FatalIOError if it is found and the number of tokens is incorrect.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
template<class T>
|
||||
T lookupOrAddDefault
|
||||
(
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
);
|
||||
|
||||
//- Find entry and assign to T val.
|
||||
//- FatalIOError if it is found and there are excess tokens.
|
||||
// Default search: non-recursive with patterns.
|
||||
//- FatalIOError if it is found and the number of tokens is incorrect,
|
||||
//- or it is mandatory and not found.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param val the value to read into
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
// \param mandatory the keyword is mandatory
|
||||
//
|
||||
// \return true if the entry was found.
|
||||
template<class T>
|
||||
@ -614,18 +617,16 @@ public:
|
||||
(
|
||||
const word& keyword,
|
||||
T& val,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true,
|
||||
enum keyType::option matchOpt = keyType::REGEX,
|
||||
bool mandatory = true
|
||||
) const;
|
||||
|
||||
//- Find an entry if present, and assign to T val.
|
||||
//- FatalIOError if it is found and there are excess tokens.
|
||||
//- FatalIOError if it is found and the number of tokens is incorrect.
|
||||
// Default search: non-recursive with patterns.
|
||||
//
|
||||
// \param val the value to read
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param val the value to read into
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
//
|
||||
// \return true if the entry was found.
|
||||
template<class T>
|
||||
@ -633,41 +634,14 @@ public:
|
||||
(
|
||||
const word& keyword,
|
||||
T& val,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return an entry pointer if present, or return a nullptr.
|
||||
// Allows scoping using '.'.
|
||||
// Special handling for an absolute anchor (^) at start of the keyword
|
||||
// and for '..' to ascend into the parent dictionaries.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
const entry* lookupScopedEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const;
|
||||
|
||||
//- Check if entry exists and is a sub-dictionary.
|
||||
//- Check if entry is found and and is a sub-dictionary.
|
||||
//
|
||||
// Search type: non-recursive with patterns.
|
||||
bool isDict(const word& keyword) const;
|
||||
|
||||
//- Find and return a sub-dictionary pointer if present
|
||||
// (and a sub-dictionary) otherwise return nullptr.
|
||||
//
|
||||
// Search type: non-recursive with patterns.
|
||||
const dictionary* subDictPtr(const word& keyword) const;
|
||||
|
||||
//- Find and return a sub-dictionary pointer if present
|
||||
// (and a sub-dictionary) otherwise return nullptr.
|
||||
//
|
||||
// Search type: non-recursive with patterns.
|
||||
dictionary* subDictPtr(const word& keyword);
|
||||
|
||||
//- Find and return a sub-dictionary.
|
||||
// Fatal if the entry does not exist or is not a sub-dictionary.
|
||||
//
|
||||
@ -856,8 +830,7 @@ public:
|
||||
const_searcher csearch
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Search dictionary for given keyword
|
||||
@ -868,8 +841,7 @@ public:
|
||||
const_searcher search
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Search dictionary for given keyword
|
||||
@ -880,8 +852,7 @@ public:
|
||||
searcher search
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
);
|
||||
|
||||
//- Search using scoping.
|
||||
@ -910,8 +881,7 @@ public:
|
||||
const_searcher csearchScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option
|
||||
) const;
|
||||
|
||||
//- Search using dot or slash scoping.
|
||||
@ -921,8 +891,7 @@ public:
|
||||
const_searcher searchScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option
|
||||
) const;
|
||||
|
||||
//- Search using dot or slash scoping.
|
||||
@ -932,25 +901,24 @@ public:
|
||||
searcher searchScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option
|
||||
);
|
||||
|
||||
//- Locate a sub-dictionary using slash-scoping
|
||||
// \return nullptr if the dictionary path does not exist
|
||||
const dictionary* cfindScopedDictPtr(const fileName& dictPath) const;
|
||||
const dictionary* cfindScopedDict(const fileName& dictPath) const;
|
||||
|
||||
//- Locate a sub-dictionary using slash-scoping
|
||||
// \return nullptr if the dictionary path does not exist
|
||||
const dictionary* findScopedDictPtr(const fileName& dictPath) const;
|
||||
const dictionary* findScopedDict(const fileName& dictPath) const;
|
||||
|
||||
//- Locate a sub-dictionary using slash-scoping
|
||||
// \return nullptr if the dictionary path does not exist
|
||||
dictionary* findScopedDictPtr(const fileName& dictPath);
|
||||
dictionary* findScopedDict(const fileName& dictPath);
|
||||
|
||||
//- Locate existing or create sub-dictionary using slash-scoping
|
||||
// \return nullptr if the dictionary path could not be created
|
||||
dictionary* makeScopedDictPtr(const fileName& dictPath);
|
||||
dictionary* makeScopedDict(const fileName& dictPath);
|
||||
|
||||
|
||||
// Compatibility helpers
|
||||
@ -969,8 +937,7 @@ public:
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Search dictionary for given keyword and any compatibility names
|
||||
@ -984,8 +951,7 @@ public:
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return an entry pointer if present, or return a nullptr,
|
||||
@ -995,12 +961,11 @@ public:
|
||||
// OpenFOAM version for which they were used.
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
const entry* lookupEntryPtrCompat
|
||||
const entry* findCompat
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option
|
||||
) const;
|
||||
|
||||
//- Find and return an entry if present, otherwise FatalIOError,
|
||||
@ -1014,8 +979,7 @@ public:
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option
|
||||
) const;
|
||||
|
||||
//- Find and return a T
|
||||
@ -1032,8 +996,7 @@ public:
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return an entry data stream,
|
||||
@ -1048,8 +1011,7 @@ public:
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return a T, or return the given default value
|
||||
@ -1066,8 +1028,7 @@ public:
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
const T& deflt,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find entry and assign to T val
|
||||
@ -1088,8 +1049,7 @@ public:
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
T& val,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true,
|
||||
enum keyType::option = keyType::REGEX,
|
||||
bool mandatory = true
|
||||
) const;
|
||||
|
||||
@ -1111,22 +1071,12 @@ public:
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
T& val,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Find and return an entry data stream (identical to #lookup method).
|
||||
// Search: non-recursive with patterns.
|
||||
//
|
||||
// \deprecated use lookup() method instead (deprecated JUL-2018)
|
||||
ITstream& operator[](const word& keyword) const
|
||||
{
|
||||
return lookup(keyword);
|
||||
}
|
||||
|
||||
//- Copy assignment
|
||||
void operator=(const dictionary& rhs);
|
||||
|
||||
@ -1152,19 +1102,196 @@ public:
|
||||
friend Ostream& operator<<(Ostream& os, const dictionary& dict);
|
||||
|
||||
|
||||
// Shortcuts - may be more useable in templated code
|
||||
// Housekeeping
|
||||
|
||||
//- Find and return an entry data stream (identical to #lookup method).
|
||||
//
|
||||
// \deprecated use lookup() method instead (JUL-2018)
|
||||
ITstream& operator[](const word& keyword) const
|
||||
{
|
||||
return lookup(keyword);
|
||||
}
|
||||
|
||||
//- Find and return a T.
|
||||
// \deprecated - same as the get() method (OCT-2018)
|
||||
template<class T>
|
||||
T lookupType
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
) const
|
||||
{
|
||||
return get<T>(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Search dictionary for given keyword.
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
bool found
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch = true
|
||||
) const
|
||||
{
|
||||
return found(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find and return an entry pointer for manipulation if present,
|
||||
//- or return a nullptr.
|
||||
//
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
entry* lookupEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
)
|
||||
{
|
||||
return findEntry(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find and return an entry pointer if present, or return a nullptr.
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
const entry* lookupEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
return findEntry(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find and return an entry pointer if present, or return a nullptr.
|
||||
// Allows scoping using '.'.
|
||||
// Special handling for an absolute anchor (^) at start of the keyword
|
||||
// and for '..' to ascend into the parent dictionaries.
|
||||
//
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
const entry* lookupScopedEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
return findScoped(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find and return a sub-dictionary pointer if present
|
||||
// (and a sub-dictionary) otherwise return nullptr.
|
||||
//
|
||||
// Search type: non-recursive with patterns.
|
||||
const dictionary* subDictPtr(const word& keyword) const
|
||||
{
|
||||
return findDict(keyword, keyType::REGEX);
|
||||
}
|
||||
|
||||
//- Find and return a sub-dictionary pointer if present
|
||||
// (and a sub-dictionary) otherwise return nullptr.
|
||||
//
|
||||
// Search type: non-recursive with patterns.
|
||||
dictionary* subDictPtr(const word& keyword)
|
||||
{
|
||||
return findDict(keyword, keyType::REGEX);
|
||||
}
|
||||
|
||||
//- Find and return an entry if present, otherwise FatalIOError.
|
||||
//
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
const entry& lookupEntry
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
return lookupEntry(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find and return an entry data stream.
|
||||
// Default search: non-recursive with patterns.
|
||||
//
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
ITstream& lookup
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch = true
|
||||
) const
|
||||
{
|
||||
return lookup(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find and return a T, or return the given default value
|
||||
//- FatalIOError if it is found and there are excess tokens.
|
||||
//
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
template<class T>
|
||||
T lookupOrDefault
|
||||
(
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive,
|
||||
bool patternMatch = true
|
||||
) const
|
||||
{
|
||||
return
|
||||
lookupOrDefault
|
||||
(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find and return a T, or return the given default value
|
||||
//- and add it to dictionary.
|
||||
//- FatalIOError if it is found and there are excess tokens.
|
||||
//
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
template<class T>
|
||||
T lookupOrAddDefault
|
||||
(
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive,
|
||||
bool patternMatch = true
|
||||
)
|
||||
{
|
||||
return
|
||||
lookupOrAddDefault
|
||||
(keyword, deflt, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find an entry if present, and assign to T val.
|
||||
//- FatalIOError if it is found and there are excess tokens.
|
||||
//
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
template<class T>
|
||||
bool readIfPresent
|
||||
(
|
||||
const word& keyword,
|
||||
T& val,
|
||||
bool recursive,
|
||||
bool patternMatch = true
|
||||
) const
|
||||
{
|
||||
return
|
||||
readIfPresent
|
||||
(keyword, val, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
|
||||
// Shortcuts - when a templated classes also inherits from a dictionary
|
||||
|
||||
#undef defineDictionaryGetter
|
||||
#define defineDictionaryGetter(Func,Type) \
|
||||
#define defineDictionaryGetter(Func, Type) \
|
||||
/** Same as get\<Type\> */ \
|
||||
Type Func \
|
||||
( \
|
||||
const word& keyword, \
|
||||
bool recursive = false, \
|
||||
bool patternMatch = true \
|
||||
enum keyType::option matchOpt = keyType::REGEX \
|
||||
) const \
|
||||
{ \
|
||||
return get<Type>(keyword, recursive, patternMatch); \
|
||||
return get<Type>(keyword, matchOpt); \
|
||||
}
|
||||
|
||||
defineDictionaryGetter(getBool, bool);
|
||||
|
||||
@ -49,11 +49,10 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchCompat
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
const_searcher finder(csearch(keyword, recursive, patternMatch));
|
||||
const_searcher finder(csearch(keyword, matchOpt));
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -62,7 +61,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchCompat
|
||||
|
||||
for (const std::pair<const char*,int>& iter : compat)
|
||||
{
|
||||
finder = csearch(word::validate(iter.first), recursive, patternMatch);
|
||||
finder = csearch(word::validate(iter.first), matchOpt);
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -99,23 +98,21 @@ bool Foam::dictionary::foundCompat
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return csearchCompat(keyword, compat, recursive, patternMatch).found();
|
||||
return csearchCompat(keyword, compat, matchOpt).found();
|
||||
}
|
||||
|
||||
|
||||
const Foam::entry* Foam::dictionary::lookupEntryPtrCompat
|
||||
const Foam::entry* Foam::dictionary::findCompat
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return csearchCompat(keyword, compat, recursive, patternMatch).ptr();
|
||||
return csearchCompat(keyword, compat, matchOpt).ptr();
|
||||
}
|
||||
|
||||
|
||||
@ -123,12 +120,10 @@ const Foam::entry& Foam::dictionary::lookupEntryCompat
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
const const_searcher
|
||||
finder(csearchCompat(keyword, compat, recursive, patternMatch));
|
||||
const const_searcher finder(csearchCompat(keyword, compat, matchOpt));
|
||||
|
||||
if (!finder.found())
|
||||
{
|
||||
@ -146,12 +141,10 @@ Foam::ITstream& Foam::dictionary::lookupCompat
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return
|
||||
lookupEntryCompat(keyword, compat, recursive, patternMatch).stream();
|
||||
return lookupEntryCompat(keyword, compat, matchOpt).stream();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -33,31 +33,26 @@ Foam::dictionary::dictionary
|
||||
(
|
||||
const fileName& name,
|
||||
const dictionary& parentDict,
|
||||
Istream& is
|
||||
Istream& is,
|
||||
bool keepHeader
|
||||
)
|
||||
:
|
||||
dictionaryName(parentDict.name() + '.' + name),
|
||||
name_(parentDict.name() + '.' + name),
|
||||
parent_(parentDict)
|
||||
{
|
||||
read(is);
|
||||
read(is, keepHeader);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary::dictionary(Istream& is)
|
||||
:
|
||||
dictionaryName(is.name()),
|
||||
parent_(dictionary::null)
|
||||
{
|
||||
// Reset input mode as this is a "top-level" dictionary
|
||||
entry::resetInputMode();
|
||||
|
||||
read(is);
|
||||
}
|
||||
dictionary(is, false)
|
||||
{}
|
||||
|
||||
|
||||
Foam::dictionary::dictionary(Istream& is, bool keepHeader)
|
||||
:
|
||||
dictionaryName(is.name()),
|
||||
name_(is.name()),
|
||||
parent_(dictionary::null)
|
||||
{
|
||||
// Reset input mode as this is a "top-level" dictionary
|
||||
|
||||
@ -69,8 +69,7 @@ namespace
|
||||
Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
auto scopePos = keyword.find('.');
|
||||
@ -78,9 +77,12 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
|
||||
if (scopePos == string::npos)
|
||||
{
|
||||
// Normal, non-scoped search
|
||||
return csearch(keyword, recursive, patternMatch);
|
||||
return csearch(keyword, matchOpt);
|
||||
}
|
||||
|
||||
// It is '.' scoped - force non-recusive searching
|
||||
matchOpt = keyType::option(matchOpt & ~(keyType::RECURSIVE));
|
||||
|
||||
if (scopePos == 0)
|
||||
{
|
||||
// Starting with a '.' -> go up for every further '.' found
|
||||
@ -113,8 +115,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
|
||||
return dictPtr->csearchDotScoped
|
||||
(
|
||||
keyword.substr(scopePos),
|
||||
false,
|
||||
patternMatch
|
||||
matchOpt
|
||||
);
|
||||
}
|
||||
|
||||
@ -122,8 +123,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
|
||||
const_searcher finder = csearchDotScoped
|
||||
(
|
||||
keyword.substr(0, scopePos),
|
||||
false,
|
||||
patternMatch
|
||||
matchOpt
|
||||
);
|
||||
|
||||
// Fall back to finding key with '.' so e.g. if keyword is
|
||||
@ -137,7 +137,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
|
||||
scopePos = keyword.find('.', scopePos+1);
|
||||
|
||||
// Local entry:
|
||||
finder = csearch(keyword.substr(0, scopePos), false, patternMatch);
|
||||
finder = csearch(keyword.substr(0, scopePos), matchOpt);
|
||||
|
||||
if (scopePos == string::npos)
|
||||
{
|
||||
@ -152,8 +152,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
|
||||
return finder.dict().csearchDotScoped
|
||||
(
|
||||
keyword.substr(scopePos),
|
||||
false,
|
||||
patternMatch
|
||||
matchOpt
|
||||
);
|
||||
}
|
||||
|
||||
@ -164,9 +163,13 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
|
||||
Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
|
||||
// With '/' scoping - recursive is never allowed
|
||||
matchOpt = keyType::option(matchOpt & ~(keyType::RECURSIVE));
|
||||
|
||||
const dictionary* dictPtr = this;
|
||||
|
||||
const auto slash = keyword.find('/');
|
||||
@ -175,7 +178,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped
|
||||
{
|
||||
// No slashes:
|
||||
// Can use normal (non-scoped) search at the current dictionary level
|
||||
return csearch(keyword, false, patternMatch);
|
||||
return csearch(keyword, matchOpt);
|
||||
}
|
||||
else if (slash == 0)
|
||||
{
|
||||
@ -220,7 +223,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped
|
||||
// Find entry
|
||||
const word key = word::validate(cmpt);
|
||||
|
||||
auto finder = dictPtr->csearch(key, false, patternMatch);
|
||||
auto finder = dictPtr->csearch(key, matchOpt);
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -259,8 +262,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped
|
||||
Foam::dictionary::const_searcher Foam::dictionary::csearch
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
const_searcher finder(this);
|
||||
@ -273,27 +275,22 @@ Foam::dictionary::const_searcher Foam::dictionary::csearch
|
||||
return finder;
|
||||
}
|
||||
|
||||
if (patternMatch && patterns_.size())
|
||||
if ((matchOpt & keyType::REGEX) && patterns_.size())
|
||||
{
|
||||
pattern_const_iterator wcLink = patterns_.begin();
|
||||
regexp_const_iterator reLink = regexps_.begin();
|
||||
|
||||
// Find in patterns using regular expressions only
|
||||
if (findInPatterns(patternMatch, keyword, wcLink, reLink))
|
||||
if (findInPatterns(true, keyword, wcLink, reLink))
|
||||
{
|
||||
finder.set(*wcLink);
|
||||
return finder;
|
||||
}
|
||||
}
|
||||
|
||||
if (recursive && &parent_ != &dictionary::null)
|
||||
if ((matchOpt & keyType::RECURSIVE) && &parent_ != &dictionary::null)
|
||||
{
|
||||
return parent_.csearch
|
||||
(
|
||||
keyword,
|
||||
recursive,
|
||||
patternMatch
|
||||
);
|
||||
return parent_.csearch(keyword, matchOpt);
|
||||
}
|
||||
|
||||
return finder;
|
||||
@ -303,22 +300,20 @@ Foam::dictionary::const_searcher Foam::dictionary::csearch
|
||||
Foam::dictionary::const_searcher Foam::dictionary::search
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return csearch(keyword, recursive, patternMatch);
|
||||
return csearch(keyword, matchOpt);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary::searcher Foam::dictionary::search
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
)
|
||||
{
|
||||
const_searcher finder = csearch(keyword, recursive, patternMatch);
|
||||
const_searcher finder = csearch(keyword, matchOpt);
|
||||
|
||||
return static_cast<const searcher&>(finder);
|
||||
}
|
||||
@ -327,17 +322,19 @@ Foam::dictionary::searcher Foam::dictionary::search
|
||||
Foam::dictionary::const_searcher Foam::dictionary::csearchScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
if (keyword.find('/') != string::npos)
|
||||
{
|
||||
return csearchSlashScoped(keyword, patternMatch);
|
||||
return csearchSlashScoped(keyword, matchOpt);
|
||||
}
|
||||
|
||||
if (keyword[0] == ':' || keyword[0] == '^')
|
||||
{
|
||||
// It is ':' scoped - force non-recusive searching
|
||||
matchOpt = keyType::option(matchOpt & ~(keyType::RECURSIVE));
|
||||
|
||||
// Ascend to top-level
|
||||
const dictionary* dictPtr = this;
|
||||
while (&dictPtr->parent_ != &dictionary::null)
|
||||
@ -345,43 +342,36 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchScoped
|
||||
dictPtr = &dictPtr->parent_;
|
||||
}
|
||||
|
||||
return dictPtr->csearchDotScoped
|
||||
(
|
||||
keyword.substr(1),
|
||||
false,
|
||||
patternMatch
|
||||
);
|
||||
return dictPtr->csearchDotScoped(keyword.substr(1), matchOpt);
|
||||
}
|
||||
|
||||
return csearchDotScoped(keyword, recursive, patternMatch);
|
||||
return csearchDotScoped(keyword, matchOpt);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary::const_searcher Foam::dictionary::searchScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return csearchScoped(keyword, recursive, patternMatch);
|
||||
return csearchScoped(keyword, matchOpt);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary::searcher Foam::dictionary::searchScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
)
|
||||
{
|
||||
const_searcher finder = csearchScoped(keyword, recursive, patternMatch);
|
||||
const_searcher finder = csearchScoped(keyword, matchOpt);
|
||||
|
||||
return static_cast<const searcher&>(finder);
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary* Foam::dictionary::cfindScopedDictPtr
|
||||
const Foam::dictionary* Foam::dictionary::cfindScopedDict
|
||||
(
|
||||
const fileName& dictPath
|
||||
) const
|
||||
@ -466,26 +456,26 @@ const Foam::dictionary* Foam::dictionary::cfindScopedDictPtr
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary* Foam::dictionary::findScopedDictPtr
|
||||
const Foam::dictionary* Foam::dictionary::findScopedDict
|
||||
(
|
||||
const fileName& dictPath
|
||||
) const
|
||||
{
|
||||
return cfindScopedDictPtr(dictPath);
|
||||
return cfindScopedDict(dictPath);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary* Foam::dictionary::findScopedDictPtr
|
||||
Foam::dictionary* Foam::dictionary::findScopedDict
|
||||
(
|
||||
const fileName& dictPath
|
||||
)
|
||||
{
|
||||
const dictionary* ptr = cfindScopedDictPtr(dictPath);
|
||||
const dictionary* ptr = cfindScopedDict(dictPath);
|
||||
return const_cast<dictionary*>(ptr);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary* Foam::dictionary::makeScopedDictPtr(const fileName& dictPath)
|
||||
Foam::dictionary* Foam::dictionary::makeScopedDict(const fileName& dictPath)
|
||||
{
|
||||
// Or warning
|
||||
if (dictPath.empty())
|
||||
@ -536,7 +526,8 @@ Foam::dictionary* Foam::dictionary::makeScopedDictPtr(const fileName& dictPath)
|
||||
else
|
||||
{
|
||||
// Non-recursive, no patternMatch
|
||||
// -> can do direct lookup, without csearch(cmptName, false, false);
|
||||
// -> can do direct lookup,
|
||||
// without csearch(cmptName, keyType::LITERAL);
|
||||
const word cmptName(cmpt.str(), false);
|
||||
|
||||
auto iter = dictPtr->hashedEntries_.find(cmptName);
|
||||
|
||||
@ -53,12 +53,11 @@ template<class T>
|
||||
T Foam::dictionary::get
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
T val;
|
||||
readEntry<T>(keyword, val, recursive, patternMatch);
|
||||
readEntry<T>(keyword, val, matchOpt);
|
||||
return val;
|
||||
}
|
||||
|
||||
@ -68,12 +67,11 @@ T Foam::dictionary::getCompat
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
T val;
|
||||
readCompat<T>(keyword, compat, val, recursive, patternMatch);
|
||||
readCompat<T>(keyword, compat, val, matchOpt);
|
||||
return val;
|
||||
}
|
||||
|
||||
@ -84,13 +82,11 @@ bool Foam::dictionary::readCompat
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
T& val,
|
||||
bool recursive,
|
||||
bool patternMatch,
|
||||
enum keyType::option matchOpt,
|
||||
bool mandatory
|
||||
) const
|
||||
{
|
||||
const const_searcher
|
||||
finder(csearchCompat(keyword, compat, recursive, patternMatch));
|
||||
const const_searcher finder(csearchCompat(keyword, compat, matchOpt));
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -113,29 +109,15 @@ bool Foam::dictionary::readCompat
|
||||
}
|
||||
|
||||
|
||||
// older name
|
||||
template<class T>
|
||||
T Foam::dictionary::lookupType
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
return get<T>(keyword, recursive, patternMatch);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
T Foam::dictionary::lookupOrDefault
|
||||
(
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
const const_searcher finder(csearch(keyword, recursive, patternMatch));
|
||||
const const_searcher finder(csearch(keyword, matchOpt));
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -165,11 +147,10 @@ T Foam::dictionary::lookupOrAddDefault
|
||||
(
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
)
|
||||
{
|
||||
const const_searcher finder(csearch(keyword, recursive, patternMatch));
|
||||
const const_searcher finder(csearch(keyword, matchOpt));
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -200,12 +181,11 @@ bool Foam::dictionary::readEntry
|
||||
(
|
||||
const word& keyword,
|
||||
T& val,
|
||||
bool recursive,
|
||||
bool patternMatch,
|
||||
enum keyType::option matchOpt,
|
||||
bool mandatory
|
||||
) const
|
||||
{
|
||||
const const_searcher finder(csearch(keyword, recursive, patternMatch));
|
||||
const const_searcher finder(csearch(keyword, matchOpt));
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -233,12 +213,11 @@ bool Foam::dictionary::readIfPresent
|
||||
(
|
||||
const word& keyword,
|
||||
T& val,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
// Read is non-mandatory
|
||||
return readEntry<T>(keyword, val, recursive, patternMatch, false);
|
||||
return readEntry<T>(keyword, val, matchOpt, false);
|
||||
}
|
||||
|
||||
|
||||
@ -248,12 +227,10 @@ T Foam::dictionary::lookupOrDefaultCompat
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
const T& deflt,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
const const_searcher
|
||||
finder(csearchCompat(keyword, compat, recursive, patternMatch));
|
||||
const const_searcher finder(csearchCompat(keyword, compat, matchOpt));
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -284,12 +261,11 @@ bool Foam::dictionary::readIfPresentCompat
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
T& val,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
// Read is non-mandatory
|
||||
return readCompat<T>(keyword, compat, val, recursive, patternMatch, false);
|
||||
return readCompat<T>(keyword, compat, val, matchOpt, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -241,7 +241,8 @@ bool Foam::entry::New
|
||||
const word varName = keyword.substr(1);
|
||||
|
||||
// Lookup the variable name in the given dictionary
|
||||
const auto finder = parentDict.csearchScoped(varName, true, true);
|
||||
const auto finder =
|
||||
parentDict.csearchScoped(varName, keyType::REGEX_RECURSIVE);
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -301,8 +302,8 @@ bool Foam::entry::New
|
||||
auto finder =
|
||||
(
|
||||
scoped
|
||||
? parentDict.searchScoped(keyword, false, false)
|
||||
: parentDict.search(keyword, false, false)
|
||||
? parentDict.searchScoped(keyword, keyType::LITERAL)
|
||||
: parentDict.search(keyword, keyType::LITERAL)
|
||||
);
|
||||
|
||||
// How to manage duplicate entries
|
||||
@ -387,10 +388,7 @@ bool Foam::entry::New
|
||||
// Get or create the dictionary-path.
|
||||
// fileName::path == dictionary-path
|
||||
dictionary* subDictPtr =
|
||||
parentDict.makeScopedDictPtr
|
||||
(
|
||||
fileName::path(fullPath)
|
||||
);
|
||||
parentDict.makeScopedDict(fileName::path(fullPath));
|
||||
|
||||
if (subDictPtr)
|
||||
{
|
||||
|
||||
@ -61,8 +61,7 @@ bool Foam::functionEntries::removeEntry::execute
|
||||
if (key.isLiteral() && key.find('/') != string::npos)
|
||||
{
|
||||
// Remove scoped keyword, or keyword in the local scope
|
||||
dictionary::searcher finder =
|
||||
parentDict.searchScoped(key, false, false);
|
||||
auto finder(parentDict.searchScoped(key, keyType::LITERAL));
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
|
||||
@ -78,7 +78,8 @@ bool Foam::primitiveEntry::expandVariable
|
||||
// The $internalField would be matched by the ".*" !!!
|
||||
|
||||
// Recursive, non-patterns
|
||||
const entry* eptr = dict.lookupScopedEntryPtr(varName, true, false);
|
||||
const entry* eptr = dict.findScoped(varName, keyType::LITERAL_RECURSIVE);
|
||||
|
||||
if (!eptr)
|
||||
{
|
||||
// Not found - revert to environment variable
|
||||
|
||||
@ -55,14 +55,14 @@ static inline void writeEntryIfPresent
|
||||
)
|
||||
{
|
||||
// non-recursive like dictionary::found, but no pattern-match either
|
||||
const entry* ptr = dict.lookupEntryPtr(key, false, false);
|
||||
const entry* eptr = dict.findEntry(key, keyType::LITERAL);
|
||||
|
||||
if (ptr)
|
||||
if (eptr)
|
||||
{
|
||||
os.writeKeyword(key)
|
||||
<< token::HASH << token::BEGIN_BLOCK;
|
||||
|
||||
os.writeQuoted(string(ptr->stream()), false)
|
||||
os.writeQuoted(string(eptr->stream()), false)
|
||||
<< token::HASH << token::END_BLOCK
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
@ -44,50 +44,40 @@ Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict)
|
||||
// - necessary for compilation options, convenient for includes
|
||||
// and body.
|
||||
|
||||
const entry* codePtr = dict.lookupEntryPtr
|
||||
(
|
||||
"code",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry* codePtr = dict.findEntry("code", keyType::LITERAL);
|
||||
|
||||
if (codePtr)
|
||||
{
|
||||
code_ = stringOps::trim(codePtr->stream());
|
||||
stringOps::inplaceExpand(code_, dict);
|
||||
}
|
||||
|
||||
const entry* includePtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeInclude",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry* includePtr = dict.findEntry("codeInclude", keyType::LITERAL);
|
||||
|
||||
if (includePtr)
|
||||
{
|
||||
include_ = stringOps::trim(includePtr->stream());
|
||||
stringOps::inplaceExpand(include_, dict);
|
||||
}
|
||||
|
||||
const entry* optionsPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeOptions",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry* optionsPtr = dict.findEntry("codeOptions", keyType::LITERAL);
|
||||
|
||||
if (optionsPtr)
|
||||
{
|
||||
options_ = stringOps::trim(optionsPtr->stream());
|
||||
stringOps::inplaceExpand(options_, dict);
|
||||
}
|
||||
|
||||
const entry* libsPtr = dict.lookupEntryPtr("codeLibs", false, false);
|
||||
const entry* libsPtr = dict.findEntry("codeLibs", keyType::LITERAL);
|
||||
|
||||
if (libsPtr)
|
||||
{
|
||||
libs_ = stringOps::trim(libsPtr->stream());
|
||||
stringOps::inplaceExpand(libs_, dict);
|
||||
}
|
||||
|
||||
const entry* localPtr = dict.lookupEntryPtr("localCode", false, false);
|
||||
const entry* localPtr = dict.findEntry("localCode", keyType::LITERAL);
|
||||
|
||||
if (localPtr)
|
||||
{
|
||||
localCode_ = stringOps::trim(localPtr->stream());
|
||||
|
||||
@ -706,12 +706,8 @@ bool Foam::functionObjectList::read()
|
||||
}
|
||||
|
||||
// Update existing and add new functionObjects
|
||||
const entry* entryPtr = parentDict_.lookupEntryPtr
|
||||
(
|
||||
"functions",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry* entryPtr =
|
||||
parentDict_.findEntry("functions", keyType::LITERAL);
|
||||
|
||||
if (entryPtr)
|
||||
{
|
||||
|
||||
@ -135,12 +135,9 @@ Foam::dictionary& Foam::debug::switchSet
|
||||
{
|
||||
if (!subDictPtr)
|
||||
{
|
||||
entry* ePtr = controlDict().lookupEntryPtr
|
||||
(
|
||||
subDictName, false, false
|
||||
);
|
||||
entry* eptr = controlDict().findEntry(subDictName, keyType::LITERAL);
|
||||
|
||||
if (!ePtr || !ePtr->isDict())
|
||||
if (!eptr || !eptr->isDict())
|
||||
{
|
||||
cerr<< "debug::switchSet(const char*, dictionary*&):\n"
|
||||
<< " Cannot find " << subDictName << " in dictionary "
|
||||
@ -150,7 +147,7 @@ Foam::dictionary& Foam::debug::switchSet
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
subDictPtr = &ePtr->dict();
|
||||
subDictPtr = &(eptr->dict());
|
||||
}
|
||||
|
||||
return *subDictPtr;
|
||||
@ -179,7 +176,7 @@ int Foam::debug::debugSwitch(const char* name, const int defaultValue)
|
||||
{
|
||||
return debugSwitches().lookupOrAddDefault
|
||||
(
|
||||
name, defaultValue, false, false
|
||||
name, defaultValue, keyType::LITERAL
|
||||
);
|
||||
}
|
||||
|
||||
@ -188,7 +185,7 @@ int Foam::debug::infoSwitch(const char* name, const int defaultValue)
|
||||
{
|
||||
return infoSwitches().lookupOrAddDefault
|
||||
(
|
||||
name, defaultValue, false, false
|
||||
name, defaultValue, keyType::LITERAL
|
||||
);
|
||||
}
|
||||
|
||||
@ -197,7 +194,7 @@ int Foam::debug::optimisationSwitch(const char* name, const int defaultValue)
|
||||
{
|
||||
return optimisationSwitches().lookupOrAddDefault
|
||||
(
|
||||
name, defaultValue, false, false
|
||||
name, defaultValue, keyType::LITERAL
|
||||
);
|
||||
}
|
||||
|
||||
@ -210,7 +207,7 @@ float Foam::debug::floatOptimisationSwitch
|
||||
{
|
||||
return optimisationSwitches().lookupOrAddDefault
|
||||
(
|
||||
name, defaultValue, false, false
|
||||
name, defaultValue, keyType::LITERAL
|
||||
);
|
||||
}
|
||||
|
||||
@ -412,17 +409,17 @@ void listSwitches
|
||||
|
||||
wordHashSet controlDictDebug
|
||||
(
|
||||
controlDict.subDict("DebugSwitches").sortedToc()
|
||||
controlDict.subDict("DebugSwitches").toc()
|
||||
);
|
||||
|
||||
wordHashSet controlDictInfo
|
||||
(
|
||||
controlDict.subDict("InfoSwitches").sortedToc()
|
||||
controlDict.subDict("InfoSwitches").toc()
|
||||
);
|
||||
|
||||
wordHashSet controlDictOpt
|
||||
(
|
||||
controlDict.subDict("OptimisationSwitches").sortedToc()
|
||||
controlDict.subDict("OptimisationSwitches").toc()
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -50,8 +50,7 @@ namespace Foam
|
||||
"fileHandler",
|
||||
//Foam::fileOperations::uncollatedFileOperation::typeName,
|
||||
"uncollated",
|
||||
false,
|
||||
false
|
||||
keyType::LITERAL
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -43,8 +43,10 @@ Foam::word Foam::lduMatrix::preconditioner::getName
|
||||
{
|
||||
word name;
|
||||
|
||||
// handle primitive or dictionary entry
|
||||
const entry& e = solverControls.lookupEntry("preconditioner", false, false);
|
||||
// Handle primitive or dictionary entry
|
||||
const entry& e =
|
||||
solverControls.lookupEntry("preconditioner", keyType::LITERAL);
|
||||
|
||||
if (e.isDict())
|
||||
{
|
||||
e.dict().readEntry("preconditioner", name);
|
||||
@ -67,8 +69,11 @@ Foam::lduMatrix::preconditioner::New
|
||||
{
|
||||
word name;
|
||||
|
||||
// handle primitive or dictionary entry
|
||||
const entry& e = solverControls.lookupEntry("preconditioner", false, false);
|
||||
// Handle primitive or dictionary entry
|
||||
|
||||
const entry& e =
|
||||
solverControls.lookupEntry("preconditioner", keyType::LITERAL);
|
||||
|
||||
if (e.isDict())
|
||||
{
|
||||
e.dict().readEntry("preconditioner", name);
|
||||
|
||||
@ -43,8 +43,10 @@ Foam::lduMatrix::smoother::getName
|
||||
{
|
||||
word name;
|
||||
|
||||
// handle primitive or dictionary entry
|
||||
const entry& e = solverControls.lookupEntry("smoother", false, false);
|
||||
// Handle primitive or dictionary entry
|
||||
const entry& e =
|
||||
solverControls.lookupEntry("smoother", keyType::LITERAL);
|
||||
|
||||
if (e.isDict())
|
||||
{
|
||||
e.dict().readEntry("smoother", name);
|
||||
@ -70,8 +72,10 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
|
||||
{
|
||||
word name;
|
||||
|
||||
// handle primitive or dictionary entry
|
||||
const entry& e = solverControls.lookupEntry("smoother", false, false);
|
||||
// Handle primitive or dictionary entry
|
||||
const entry& e =
|
||||
solverControls.lookupEntry("smoother", keyType::LITERAL);
|
||||
|
||||
if (e.isDict())
|
||||
{
|
||||
e.dict().readEntry("smoother", name);
|
||||
|
||||
@ -35,9 +35,9 @@ namespace Foam
|
||||
|
||||
// List of sub-dictionaries to rewrite
|
||||
static const Foam::List<Foam::word> subDictNames
|
||||
{
|
||||
({
|
||||
"preconditioner", "smoother"
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
@ -184,14 +184,13 @@ Foam::label Foam::solution::upgradeSolverDict
|
||||
// 1) primitiveEntry w/o settings,
|
||||
// 2) or a dictionaryEntry.
|
||||
// transform primitiveEntry with settings -> dictionaryEntry
|
||||
forAll(subDictNames, dictI)
|
||||
for (const word& dictName : subDictNames)
|
||||
{
|
||||
const word& dictName = subDictNames[dictI];
|
||||
entry* ePtr = subdict.lookupEntryPtr(dictName,false,false);
|
||||
entry* eptr = subdict.findEntry(dictName, keyType::LITERAL);
|
||||
|
||||
if (ePtr && !ePtr->isDict())
|
||||
if (eptr && !eptr->isDict())
|
||||
{
|
||||
Istream& is = ePtr->stream();
|
||||
Istream& is = eptr->stream();
|
||||
is >> name;
|
||||
|
||||
if (!is.eof())
|
||||
@ -234,10 +233,8 @@ bool Foam::solution::cache(const word& name) const
|
||||
|
||||
return cache_.found(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ Foam::autoPtr<Foam::Function1<Type>> Foam::Function1<Type>::New
|
||||
}
|
||||
else
|
||||
{
|
||||
Istream& is(dict.lookup(entryName, false));
|
||||
Istream& is = dict.lookup(entryName); // non-recursive, allow patterns
|
||||
|
||||
token firstToken(is);
|
||||
word Function1Type;
|
||||
|
||||
@ -82,6 +82,20 @@ public:
|
||||
static const keyType null;
|
||||
|
||||
|
||||
// Public data types
|
||||
|
||||
//- Enumeration for search/match modes as bitmask
|
||||
// eg, (keyType::REGEX | keyType::RECURSIVE)
|
||||
enum option
|
||||
{
|
||||
LITERAL = 0, //!< String literal
|
||||
REGEX = 1, //!< Regular expression
|
||||
RECURSIVE = 0x10, //!< Recursive search (eg, in dictionary)
|
||||
LITERAL_RECURSIVE = (LITERAL | RECURSIVE),
|
||||
REGEX_RECURSIVE = (REGEX | RECURSIVE)
|
||||
};
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
@ -100,19 +114,19 @@ public:
|
||||
inline keyType(const char* s);
|
||||
|
||||
//- Copy construct from std::string with specified treatment
|
||||
inline keyType(const std::string& s, const bool isPattern);
|
||||
inline keyType(const std::string& s, bool isPattern);
|
||||
|
||||
//- Move construct, retaining type (literal or regex)
|
||||
inline keyType(keyType&& s);
|
||||
|
||||
//- Move construct from word. Not treated as a regular expression
|
||||
//- Move construct from word, treat as literal.
|
||||
inline keyType(word&& s);
|
||||
|
||||
//- Move construct from string. Treat as regular expression.
|
||||
//- Move construct from string, treat as regular expression.
|
||||
inline keyType(string&& s);
|
||||
|
||||
//- Move construct from std::string with specified treatment
|
||||
inline keyType(std::string&& s, const bool isPattern);
|
||||
inline keyType(std::string&& s, bool isPattern);
|
||||
|
||||
//- Construct from Istream
|
||||
// Treat as regular expression if surrounded by quotation marks.
|
||||
|
||||
@ -77,7 +77,7 @@ inline Foam::keyType::keyType(const char* s)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::keyType::keyType(const std::string& s, const bool isPattern)
|
||||
inline Foam::keyType::keyType(const std::string& s, bool isPattern)
|
||||
:
|
||||
word(s, false),
|
||||
isPattern_(isPattern)
|
||||
@ -107,7 +107,7 @@ inline Foam::keyType::keyType(string&& s)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::keyType::keyType(std::string&& s, const bool isPattern)
|
||||
inline Foam::keyType::keyType(std::string&& s, bool isPattern)
|
||||
:
|
||||
word(std::move(s), false),
|
||||
isPattern_(isPattern)
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -437,7 +437,7 @@ Foam::string Foam::stringOps::getVariable
|
||||
{
|
||||
string value;
|
||||
|
||||
const entry* eptr = dict.lookupScopedEntryPtr(name, true, false);
|
||||
const entry* eptr = dict.findScoped(name, keyType::LITERAL_RECURSIVE);
|
||||
|
||||
if (eptr)
|
||||
{
|
||||
@ -720,20 +720,16 @@ void Foam::stringOps::inplaceExpand
|
||||
varBeg + 1 + delim,
|
||||
varEnd - varBeg - 2*delim
|
||||
),
|
||||
false
|
||||
false // Already validated
|
||||
);
|
||||
|
||||
|
||||
// Lookup in the dictionary without wildcards.
|
||||
// See note in primitiveEntry
|
||||
const entry* eptr = dict.lookupScopedEntryPtr
|
||||
(
|
||||
varName,
|
||||
true,
|
||||
false
|
||||
);
|
||||
const entry* eptr =
|
||||
dict.findScoped(varName, keyType::LITERAL_RECURSIVE);
|
||||
|
||||
// if defined - copy its entries
|
||||
// Copy its entries if defined
|
||||
if (eptr)
|
||||
{
|
||||
OStringStream buf;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -96,14 +96,14 @@ public:
|
||||
// Note that 'REGEX' is implicit if 'ICASE' is specified alone.
|
||||
enum compOption
|
||||
{
|
||||
LITERAL = 0, //!< Treat as a string literal
|
||||
DETECT = 1, //!< Detect if the string contains meta-characters
|
||||
UNKNOWN = 1, //!< Unknown content.
|
||||
REGEX = 2, //!< Treat as regular expression
|
||||
ICASE = 4, //!< Ignore case in regular expression
|
||||
NOCASE = 4, //!< \deprecated Alias for ICASE (deprecated APR-2018)
|
||||
LITERAL = 0, //!< String literal
|
||||
REGEX = 1, //!< Regular expression
|
||||
ICASE = 2, //!< Ignore case in regular expression
|
||||
NOCASE = 2, //!< \deprecated Alias for ICASE (deprecated APR-2018)
|
||||
DETECT = 4, //!< Detect if the string contains meta-characters
|
||||
UNKNOWN = 4, //!< Unknown content.
|
||||
REGEX_ICASE = (REGEX|ICASE), //!< Combined REGEX and ICASE
|
||||
DETECT_ICASE = (DETECT|ICASE), //!< Combined DETECT and ICASE
|
||||
REGEX_ICASE = (REGEX|ICASE) //!< Combined REGEX and ICASE
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -62,53 +62,59 @@ bool Foam::motionSmootherAlgo::checkMesh
|
||||
{
|
||||
const scalar maxNonOrtho
|
||||
(
|
||||
dict.get<scalar>("maxNonOrtho", true)
|
||||
dict.get<scalar>("maxNonOrtho", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minVol
|
||||
(
|
||||
dict.get<scalar>("minVol", true)
|
||||
dict.get<scalar>("minVol", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minTetQuality
|
||||
(
|
||||
dict.get<scalar>("minTetQuality", true)
|
||||
dict.get<scalar>("minTetQuality", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar maxConcave
|
||||
(
|
||||
dict.get<scalar>("maxConcave", true)
|
||||
dict.get<scalar>("maxConcave", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minArea
|
||||
(
|
||||
dict.get<scalar>("minArea", true)
|
||||
dict.get<scalar>("minArea", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar maxIntSkew
|
||||
(
|
||||
dict.get<scalar>("maxInternalSkewness", true)
|
||||
dict.get<scalar>("maxInternalSkewness", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar maxBounSkew
|
||||
(
|
||||
dict.get<scalar>("maxBoundarySkewness", true)
|
||||
dict.get<scalar>("maxBoundarySkewness", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minWeight
|
||||
(
|
||||
dict.get<scalar>("minFaceWeight", true)
|
||||
dict.get<scalar>("minFaceWeight", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minVolRatio
|
||||
(
|
||||
dict.get<scalar>("minVolRatio", true)
|
||||
dict.get<scalar>("minVolRatio", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minTwist
|
||||
(
|
||||
dict.get<scalar>("minTwist", true)
|
||||
dict.get<scalar>("minTwist", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minTriangleTwist
|
||||
(
|
||||
dict.get<scalar>("minTriangleTwist", true)
|
||||
dict.get<scalar>("minTriangleTwist", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
|
||||
const scalar minFaceFlatness
|
||||
(
|
||||
dict.lookupOrDefault<scalar>
|
||||
(
|
||||
"minFaceFlatness", -1, keyType::REGEX_RECURSIVE
|
||||
)
|
||||
);
|
||||
scalar minFaceFlatness = -1.0;
|
||||
dict.readIfPresent("minFaceFlatness", minFaceFlatness, true);
|
||||
const scalar minDet
|
||||
(
|
||||
dict.get<scalar>("minDeterminant", true)
|
||||
dict.get<scalar>("minDeterminant", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
label nWrongFaces = 0;
|
||||
|
||||
@ -467,53 +473,58 @@ bool Foam::motionSmootherAlgo::checkMesh
|
||||
{
|
||||
const scalar maxNonOrtho
|
||||
(
|
||||
dict.get<scalar>("maxNonOrtho", true)
|
||||
dict.get<scalar>("maxNonOrtho", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minVol
|
||||
(
|
||||
dict.get<scalar>("minVol", true)
|
||||
dict.get<scalar>("minVol", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minTetQuality
|
||||
(
|
||||
dict.get<scalar>("minTetQuality", true)
|
||||
dict.get<scalar>("minTetQuality", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar maxConcave
|
||||
(
|
||||
dict.get<scalar>("maxConcave", true)
|
||||
dict.get<scalar>("maxConcave", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minArea
|
||||
(
|
||||
dict.get<scalar>("minArea", true)
|
||||
dict.get<scalar>("minArea", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar maxIntSkew
|
||||
(
|
||||
dict.get<scalar>("maxInternalSkewness", true)
|
||||
dict.get<scalar>("maxInternalSkewness", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar maxBounSkew
|
||||
(
|
||||
dict.get<scalar>("maxBoundarySkewness", true)
|
||||
dict.get<scalar>("maxBoundarySkewness", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minWeight
|
||||
(
|
||||
dict.get<scalar>("minFaceWeight", true)
|
||||
dict.get<scalar>("minFaceWeight", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minVolRatio
|
||||
(
|
||||
dict.get<scalar>("minVolRatio", true)
|
||||
dict.get<scalar>("minVolRatio", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minTwist
|
||||
(
|
||||
dict.get<scalar>("minTwist", true)
|
||||
dict.get<scalar>("minTwist", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minTriangleTwist
|
||||
(
|
||||
dict.get<scalar>("minTriangleTwist", true)
|
||||
dict.get<scalar>("minTriangleTwist", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
const scalar minFaceFlatness
|
||||
(
|
||||
dict.lookupOrDefault<scalar>
|
||||
(
|
||||
"minFaceFlatness", -1, keyType::REGEX_RECURSIVE
|
||||
)
|
||||
);
|
||||
scalar minFaceFlatness = -1.0;
|
||||
dict.readIfPresent("minFaceFlatness", minFaceFlatness, true);
|
||||
const scalar minDet
|
||||
(
|
||||
dict.get<scalar>("minDeterminant", true)
|
||||
dict.get<scalar>("minDeterminant", keyType::REGEX_RECURSIVE)
|
||||
);
|
||||
label nWrongFaces = 0;
|
||||
|
||||
|
||||
@ -170,7 +170,7 @@ Foam::loopControl::loopControl
|
||||
loopControl(runTime, 0, dictName)
|
||||
{
|
||||
// The loop sub-dictionary
|
||||
const dictionary* dictptr = algorithmDict.subDictPtr(dictName);
|
||||
const dictionary* dictptr = algorithmDict.findDict(dictName);
|
||||
|
||||
if (dictptr)
|
||||
{
|
||||
@ -192,13 +192,12 @@ Foam::loopControl::loopControl
|
||||
fvSolution fvsol(time_);
|
||||
|
||||
// Eg, PIMPLE or SIMPLE from <system/fvSolution>
|
||||
const dictionary* dictptr =
|
||||
fvsol.solutionDict().subDictPtr(algorithmName);
|
||||
const dictionary* dictptr = fvsol.solutionDict().findDict(algorithmName);
|
||||
|
||||
if (dictptr)
|
||||
{
|
||||
// The loop sub-dictionary
|
||||
dictptr = dictptr->subDictPtr(dictName);
|
||||
dictptr = dictptr->findDict(dictName);
|
||||
|
||||
if (dictptr)
|
||||
{
|
||||
|
||||
@ -193,12 +193,7 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
|
||||
|
||||
dict.readCompat<word>("name", {{"redirectType", 1706}}, name_);
|
||||
|
||||
const entry* dataPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeData",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry* dataPtr = dict.findEntry("codeData", keyType::LITERAL);
|
||||
if (dataPtr)
|
||||
{
|
||||
codeData_ = stringOps::trim(dataPtr->stream());
|
||||
@ -211,12 +206,7 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
|
||||
);
|
||||
}
|
||||
|
||||
const entry* readPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeRead",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry* readPtr = dict.findEntry("codeRead", keyType::LITERAL);
|
||||
if (readPtr)
|
||||
{
|
||||
codeRead_ = stringOps::trim(readPtr->stream());
|
||||
@ -229,12 +219,7 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
|
||||
);
|
||||
}
|
||||
|
||||
const entry* execPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeExecute",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry* execPtr = dict.findEntry("codeExecute", keyType::LITERAL);
|
||||
if (execPtr)
|
||||
{
|
||||
codeExecute_ = stringOps::trim(execPtr->stream());
|
||||
@ -247,12 +232,7 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
|
||||
);
|
||||
}
|
||||
|
||||
const entry* writePtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeWrite",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry* writePtr = dict.findEntry("codeWrite", keyType::LITERAL);
|
||||
if (writePtr)
|
||||
{
|
||||
codeWrite_ = stringOps::trim(writePtr->stream());
|
||||
@ -265,12 +245,7 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
|
||||
);
|
||||
}
|
||||
|
||||
const entry* endPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeEnd",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry* endPtr = dict.findEntry("codeEnd", keyType::LITERAL);
|
||||
if (endPtr)
|
||||
{
|
||||
codeEnd_ = stringOps::trim(endPtr->stream());
|
||||
@ -283,7 +258,7 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
|
||||
);
|
||||
}
|
||||
|
||||
if(!dataPtr && !readPtr && !execPtr && !writePtr && !endPtr)
|
||||
if (!dataPtr && !readPtr && !execPtr && !writePtr && !endPtr)
|
||||
{
|
||||
IOWarningInFunction
|
||||
(
|
||||
|
||||
@ -40,12 +40,9 @@ bool Foam::fv::CodedSource<Type>::read(const dictionary& dict)
|
||||
|
||||
// Code snippets
|
||||
{
|
||||
const entry& e = coeffs_.lookupEntry
|
||||
(
|
||||
"codeCorrect",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry& e =
|
||||
coeffs_.lookupEntry("codeCorrect", keyType::LITERAL);
|
||||
|
||||
codeCorrect_ = stringOps::trim(e.stream());
|
||||
stringOps::inplaceExpand(codeCorrect_, coeffs_);
|
||||
dynamicCodeContext::addLineDirective
|
||||
@ -57,12 +54,9 @@ bool Foam::fv::CodedSource<Type>::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
{
|
||||
const entry& e = coeffs_.lookupEntry
|
||||
(
|
||||
"codeAddSup",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry& e =
|
||||
coeffs_.lookupEntry("codeAddSup", keyType::LITERAL);
|
||||
|
||||
codeAddSup_ = stringOps::trim(e.stream());
|
||||
stringOps::inplaceExpand(codeAddSup_, coeffs_);
|
||||
dynamicCodeContext::addLineDirective
|
||||
@ -74,12 +68,9 @@ bool Foam::fv::CodedSource<Type>::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
{
|
||||
const entry& e = coeffs_.lookupEntry
|
||||
(
|
||||
"codeSetValue",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry& e =
|
||||
coeffs_.lookupEntry("codeSetValue", keyType::LITERAL);
|
||||
|
||||
codeSetValue_ = stringOps::trim(e.stream());
|
||||
stringOps::inplaceExpand(codeSetValue_, coeffs_);
|
||||
dynamicCodeContext::addLineDirective
|
||||
|
||||
@ -300,7 +300,7 @@ void Foam::lumpedPointMovement::readDict(const dictionary& dict)
|
||||
|
||||
const dictionary* scaleDict = nullptr;
|
||||
|
||||
if ((scaleDict = commDict.subDictPtr("scaleInput")))
|
||||
if ((scaleDict = commDict.findDict("scaleInput")))
|
||||
{
|
||||
for (int i=0; i < scaleInput_.size(); ++i)
|
||||
{
|
||||
@ -318,7 +318,7 @@ void Foam::lumpedPointMovement::readDict(const dictionary& dict)
|
||||
}
|
||||
}
|
||||
|
||||
if ((scaleDict = commDict.subDictPtr("scaleOutput")))
|
||||
if ((scaleDict = commDict.findDict("scaleOutput")))
|
||||
{
|
||||
for (int i=0; i < scaleOutput_.size(); ++i)
|
||||
{
|
||||
|
||||
@ -369,7 +369,7 @@ void Foam::blockDescriptor::write
|
||||
const dictionary& d
|
||||
)
|
||||
{
|
||||
const dictionary* varDictPtr = d.subDictPtr("namedBlocks");
|
||||
const dictionary* varDictPtr = d.findDict("namedBlocks");
|
||||
if (varDictPtr)
|
||||
{
|
||||
blockMeshTools::write(os, val, *varDictPtr);
|
||||
|
||||
@ -350,7 +350,7 @@ Foam::autoPtr<Foam::polyMesh> Foam::blockMesh::createTopology
|
||||
// Read the names/types for the unassigned patch faces
|
||||
// this is a bit heavy handed (and ugly), but there is currently
|
||||
// no easy way to rename polyMesh patches subsequently
|
||||
if (const dictionary* dictPtr = meshDescription.subDictPtr("defaultPatch"))
|
||||
if (const dictionary* dictPtr = meshDescription.findDict("defaultPatch"))
|
||||
{
|
||||
dictPtr->readIfPresent("name", defaultPatchName);
|
||||
dictPtr->readIfPresent("type", defaultPatchType);
|
||||
|
||||
@ -42,16 +42,13 @@ void Foam::blockMeshTools::read
|
||||
else if (t.isWord())
|
||||
{
|
||||
const word& varName = t.wordToken();
|
||||
const entry* ePtr = dict.lookupScopedEntryPtr
|
||||
(
|
||||
varName,
|
||||
true,
|
||||
true
|
||||
);
|
||||
if (ePtr)
|
||||
const entry* eptr =
|
||||
dict.findScoped(varName, keyType::REGEX_RECURSIVE);
|
||||
|
||||
if (eptr)
|
||||
{
|
||||
// Read as label
|
||||
val = Foam::readLabel(ePtr->stream());
|
||||
val = Foam::readLabel(eptr->stream());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -104,7 +104,7 @@ Foam::autoPtr<Foam::blockVertex> Foam::blockVertex::New
|
||||
|
||||
Foam::label Foam::blockVertex::read(Istream& is, const dictionary& dict)
|
||||
{
|
||||
const dictionary* varDictPtr = dict.subDictPtr("namedVertices");
|
||||
const dictionary* varDictPtr = dict.findDict("namedVertices");
|
||||
if (varDictPtr)
|
||||
{
|
||||
return blockMeshTools::read(is, *varDictPtr);
|
||||
@ -120,7 +120,7 @@ void Foam::blockVertex::write
|
||||
const dictionary& d
|
||||
)
|
||||
{
|
||||
const dictionary* varDictPtr = d.subDictPtr("namedVertices");
|
||||
const dictionary* varDictPtr = d.findDict("namedVertices");
|
||||
if (varDictPtr)
|
||||
{
|
||||
blockMeshTools::write(os, val, *varDictPtr);
|
||||
|
||||
@ -53,10 +53,10 @@ Foam::blockVertices::namedVertex::namedVertex
|
||||
{
|
||||
dictionary& d = const_cast<dictionary&>(dict);
|
||||
|
||||
dictionary* varDictPtr = d.subDictPtr("namedVertices");
|
||||
dictionary* varDictPtr = d.findDict("namedVertices");
|
||||
if (varDictPtr)
|
||||
{
|
||||
const_cast<dictionary&>(*varDictPtr).add(name_, index);
|
||||
varDictPtr->add(name_, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -54,10 +54,10 @@ Foam::blocks::namedBlock::namedBlock
|
||||
block(dict, index, vertices, edges, faces, is)
|
||||
{
|
||||
dictionary& d = const_cast<dictionary&>(dict);
|
||||
dictionary* varDictPtr = d.subDictPtr("namedBlocks");
|
||||
dictionary* varDictPtr = d.findDict("namedBlocks");
|
||||
if (varDictPtr)
|
||||
{
|
||||
const_cast<dictionary&>(*varDictPtr).add(*this, index);
|
||||
varDictPtr->add(*this, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -1205,7 +1205,8 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCellsGeometric
|
||||
const labelList allFaces(identity(mesh_.nFaces()));
|
||||
label nWrongFaces = 0;
|
||||
|
||||
//const scalar minV(motionDict.get<scalar>("minVol", true));
|
||||
//const scalar minV
|
||||
//(motionDict.get<scalar>("minVol", keyType::REGEX_RECURSIVE));
|
||||
//if (minV > -GREAT)
|
||||
//{
|
||||
// polyMeshGeometry::checkFacePyramids
|
||||
|
||||
@ -184,7 +184,8 @@ Foam::refinementSurfaces::refinementSurfaces
|
||||
{
|
||||
const word& geomName = allGeometry_.names()[geomI];
|
||||
|
||||
const entry* ePtr = surfacesDict.lookupEntryPtr(geomName, false, true);
|
||||
const entry* ePtr =
|
||||
surfacesDict.findEntry(geomName, keyType::LITERAL);
|
||||
|
||||
if (ePtr)
|
||||
{
|
||||
|
||||
@ -578,13 +578,11 @@ Foam::shellSurfaces::shellSurfaces
|
||||
|
||||
// Count number of shells.
|
||||
label shellI = 0;
|
||||
forAll(allGeometry.names(), geomI)
|
||||
for (const word& geomName : allGeometry_.names())
|
||||
{
|
||||
const word& geomName = allGeometry_.names()[geomI];
|
||||
|
||||
if (shellsDict.found(geomName))
|
||||
{
|
||||
shellI++;
|
||||
++shellI;
|
||||
}
|
||||
}
|
||||
|
||||
@ -615,12 +613,12 @@ Foam::shellSurfaces::shellSurfaces
|
||||
{
|
||||
const word& geomName = allGeometry_.names()[geomI];
|
||||
|
||||
const entry* ePtr = shellsDict.lookupEntryPtr(geomName, false, true);
|
||||
const entry* eptr = shellsDict.findEntry(geomName, keyType::LITERAL);
|
||||
|
||||
if (ePtr)
|
||||
if (eptr)
|
||||
{
|
||||
const dictionary& dict = ePtr->dict();
|
||||
unmatchedKeys.erase(ePtr->keyword());
|
||||
const dictionary& dict = eptr->dict();
|
||||
unmatchedKeys.erase(eptr->keyword());
|
||||
|
||||
shells_[shellI] = geomI;
|
||||
modes_[shellI] = refineModeNames_.lookup("mode", dict);
|
||||
@ -637,12 +635,9 @@ Foam::shellSurfaces::shellSurfaces
|
||||
labelPair(labelMax, labelMin),
|
||||
labelVector::zero
|
||||
);
|
||||
const entry* levelPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"levelIncrement",
|
||||
false,
|
||||
true
|
||||
);
|
||||
const entry* levelPtr =
|
||||
dict.findEntry("levelIncrement", keyType::REGEX);
|
||||
|
||||
if (levelPtr)
|
||||
{
|
||||
// Do reading ourselves since using labelPair would require
|
||||
|
||||
@ -78,7 +78,7 @@ void Foam::coordinateSystem::assign(const dictionary& dict)
|
||||
const auto finder = dict.csearchCompat
|
||||
(
|
||||
"rotation", {{"coordinateRotation", -1806}},
|
||||
false, false
|
||||
keyType::LITERAL
|
||||
);
|
||||
|
||||
if (finder.isDict())
|
||||
|
||||
@ -42,7 +42,7 @@ const Foam::dictionary* Foam::coordinateSystem::subDictCompat
|
||||
{
|
||||
// Non-recursive, no pattern matching in the search
|
||||
const auto finder =
|
||||
dictPtr->csearch(coordinateSystem::typeName_(), false, false);
|
||||
dictPtr->csearch(coordinateSystem::typeName_(), keyType::LITERAL);
|
||||
|
||||
if (finder.isDict())
|
||||
{
|
||||
|
||||
@ -100,7 +100,7 @@ Foam::fileName Foam::triSurfaceMesh::checkFile
|
||||
)
|
||||
{
|
||||
fileName fName;
|
||||
if (dict.readIfPresent("file", fName, false, false))
|
||||
if (dict.readIfPresent("file", fName, keyType::LITERAL))
|
||||
{
|
||||
fName = relativeFilePath(io, fName, isGlobal);
|
||||
|
||||
@ -318,7 +318,7 @@ Foam::triSurfaceMesh::triSurfaceMesh
|
||||
outsideVolType_(volumeType::UNKNOWN)
|
||||
{
|
||||
// Reading from supplied file name instead of objectPath/filePath
|
||||
if (dict.readIfPresent("file", fName_, false, false))
|
||||
if (dict.readIfPresent("file", fName_, keyType::LITERAL))
|
||||
{
|
||||
fName_ = relativeFilePath
|
||||
(
|
||||
@ -418,7 +418,7 @@ Foam::triSurfaceMesh::triSurfaceMesh
|
||||
outsideVolType_(volumeType::UNKNOWN)
|
||||
{
|
||||
// Reading from supplied file name instead of objectPath/filePath
|
||||
if (dict.readIfPresent("file", fName_, false, false))
|
||||
if (dict.readIfPresent("file", fName_, keyType::LITERAL))
|
||||
{
|
||||
fName_ = relativeFilePath
|
||||
(
|
||||
|
||||
@ -306,11 +306,11 @@ bool Foam::dynamicOversetFvMesh::interpolateFields()
|
||||
// Use whatever the solver has set up as suppression list
|
||||
const dictionary* dictPtr
|
||||
(
|
||||
this->schemesDict().subDictPtr("oversetInterpolationSuppressed")
|
||||
this->schemesDict().findDict("oversetInterpolationSuppressed")
|
||||
);
|
||||
if (dictPtr)
|
||||
{
|
||||
suppressed.insert(dictPtr->sortedToc());
|
||||
suppressed.insert(dictPtr->toc());
|
||||
}
|
||||
|
||||
interpolate<volScalarField>(suppressed);
|
||||
|
||||
@ -136,12 +136,12 @@ void Foam::oversetFvPatchField<Type>::initEvaluate
|
||||
|
||||
const dictionary* dictPtr
|
||||
(
|
||||
fvSchemes.subDictPtr("oversetInterpolationSuppressed")
|
||||
fvSchemes.findDict("oversetInterpolationSuppressed")
|
||||
);
|
||||
|
||||
if (dictPtr)
|
||||
{
|
||||
suppressed.insert(dictPtr->sortedToc());
|
||||
suppressed.insert(dictPtr->toc());
|
||||
}
|
||||
|
||||
if (!suppressed.found(fldName))
|
||||
|
||||
@ -121,7 +121,7 @@ void Foam::decompositionMethod::readConstraints()
|
||||
// Read any constraints
|
||||
wordList constraintTypes;
|
||||
|
||||
const dictionary* dictptr = decompositionDict_.subDictPtr("constraints");
|
||||
const dictionary* dictptr = decompositionDict_.findDict("constraints");
|
||||
|
||||
if (dictptr)
|
||||
{
|
||||
|
||||
@ -68,9 +68,9 @@ void Foam::multiLevelDecomp::createMethodsDict()
|
||||
if
|
||||
(
|
||||
// non-recursive, no patterns
|
||||
coeffsDict_.readIfPresent("method", defaultMethod, false, false)
|
||||
coeffsDict_.readIfPresent("method", defaultMethod, keyType::LITERAL)
|
||||
// non-recursive, no patterns
|
||||
&& coeffsDict_.readIfPresent("domains", domains, false, false)
|
||||
&& coeffsDict_.readIfPresent("domains", domains, keyType::LITERAL)
|
||||
)
|
||||
{
|
||||
// Short-cut version specified by method, domains only
|
||||
@ -169,14 +169,14 @@ void Foam::multiLevelDecomp::createMethodsDict()
|
||||
(
|
||||
iter().isDict()
|
||||
// non-recursive, no patterns
|
||||
&& iter().dict().found("numberOfSubdomains", false, false)
|
||||
&& iter().dict().found("numberOfSubdomains", keyType::LITERAL)
|
||||
)
|
||||
{
|
||||
// No method specified? can use a default method?
|
||||
|
||||
const bool addDefaultMethod
|
||||
(
|
||||
!(iter().dict().found("method", false, false))
|
||||
!(iter().dict().found("method", keyType::LITERAL))
|
||||
&& !defaultMethod.empty()
|
||||
);
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ Foam::label Foam::metisDecomp::decomposeSerial
|
||||
word method("recursive");
|
||||
|
||||
const dictionary* coeffsDictPtr =
|
||||
decompositionDict_.subDictPtr("metisCoeffs");
|
||||
decompositionDict_.findDict("metisCoeffs");
|
||||
|
||||
label numCells = xadj.size()-1;
|
||||
|
||||
|
||||
@ -149,9 +149,9 @@ bool Foam::regionModels::regionModel::read()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
if (const dictionary* dictPtr = subDictPtr(modelName_ + "Coeffs"))
|
||||
if (const dictionary* dictptr = findDict(modelName_ + "Coeffs"))
|
||||
{
|
||||
coeffs_ <<= *dictPtr;
|
||||
coeffs_ <<= *dictptr;
|
||||
}
|
||||
|
||||
infoOutput_.readIfPresent("infoOutput", *this);
|
||||
@ -159,10 +159,8 @@ bool Foam::regionModels::regionModel::read()
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -170,18 +168,16 @@ bool Foam::regionModels::regionModel::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
if (const dictionary* dictPtr = dict.subDictPtr(modelName_ + "Coeffs"))
|
||||
if (const dictionary* dictptr = dict.findDict(modelName_ + "Coeffs"))
|
||||
{
|
||||
coeffs_ <<= *dictPtr;
|
||||
coeffs_ <<= *dictptr;
|
||||
}
|
||||
|
||||
infoOutput_.readIfPresent("infoOutput", dict);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user