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:
@ -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())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user