ENH: replace keyType with wordRe for matching selectors.

- The keyType is primarily used within dictionary reading, whereas
  wordRe and wordRes are used for selectors in code.
  Unifying on wordRe and wordRes reduces the number matching options.
This commit is contained in:
Mark Olesen
2021-04-08 13:42:38 +02:00
committed by Andrew Heather
parent 95cd8ee75c
commit 2b7b3700c2
28 changed files with 255 additions and 367 deletions

View File

@ -157,18 +157,17 @@ Foam::wordList Foam::faBoundaryMesh::types() const
Foam::labelList Foam::faBoundaryMesh::indices
(
const keyType& key,
const wordRe& matcher,
const bool useGroups // ignored
) const
{
if (key.empty())
if (matcher.empty())
{
return labelList();
}
if (key.isPattern())
if (matcher.isPattern())
{
const regExp matcher(key);
return PtrListOps::findMatching(*this, matcher);
}
else
@ -176,7 +175,6 @@ Foam::labelList Foam::faBoundaryMesh::indices
// Literal string.
// Special version of above for reduced memory footprint
const word& matcher = key;
const label patchId = PtrListOps::firstMatching(*this, matcher);
if (patchId >= 0)
@ -189,24 +187,13 @@ Foam::labelList Foam::faBoundaryMesh::indices
}
Foam::label Foam::faBoundaryMesh::findIndex(const keyType& key) const
Foam::label Foam::faBoundaryMesh::findIndex(const wordRe& key) const
{
if (key.empty())
{
return -1;
}
else if (key.isPattern())
{
// Find as regex
const regExp matcher(key);
return PtrListOps::firstMatching(*this, matcher);
}
else
{
// Find as literal string
const word& matcher = key;
return PtrListOps::firstMatching(*this, matcher);
}
return PtrListOps::firstMatching(*this, key);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -135,13 +135,13 @@ public:
// \note Matching patchGroups currently not supported
labelList indices
(
const keyType& key,
const wordRe& matcher,
const bool useGroups = false /* ignored */
) const;
//- Return patch index for the first match, return -1 if not found
// A no-op (returns -1) for an empty key
label findIndex(const keyType& key) const;
label findIndex(const wordRe& key) const;
//- Find patch index given a name, return -1 if not found
// A no-op (returns -1) for an empty name
@ -175,11 +175,7 @@ public:
//- Identical to the indices() method (AUG-2018)
FOAM_DEPRECATED_FOR(2018-08, "indices() method")
labelList findIndices
(
const keyType& key,
const bool useGroups = false
) const
labelList findIndices(const wordRe& key, bool useGroups=false) const
{
return indices(key, useGroups);
}