mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: single-string findStrings deprecated in favour of stringOps::match
- reduces ambiguity between matching a list of strings and a single string.
This commit is contained in:
@ -79,7 +79,7 @@ Usage
|
||||
#include "tensorIOField.H"
|
||||
#include "passiveParticleCloud.H"
|
||||
#include "faceSet.H"
|
||||
#include "stringListOps.H"
|
||||
#include "stringOps.H"
|
||||
#include "wordReList.H"
|
||||
|
||||
#include "meshSubsetHelper.H"
|
||||
@ -137,7 +137,7 @@ labelList getSelectedPatches
|
||||
Info<< " discarding empty/processor patch " << patchi
|
||||
<< " " << pp.name() << endl;
|
||||
}
|
||||
else if (findStrings(excludePatches, pp.name()))
|
||||
else if (stringOps::match(excludePatches, pp.name()))
|
||||
{
|
||||
Info<< " excluding patch " << patchi
|
||||
<< " " << pp.name() << endl;
|
||||
|
||||
@ -154,7 +154,7 @@ Note
|
||||
#include "faceZoneMesh.H"
|
||||
#include "Cloud.H"
|
||||
#include "passiveParticle.H"
|
||||
#include "stringListOps.H"
|
||||
#include "stringOps.H"
|
||||
|
||||
#include "meshSubsetHelper.H"
|
||||
#include "readFields.H"
|
||||
@ -1172,7 +1172,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
const polyPatch& pp = patches[patchi];
|
||||
|
||||
if (findStrings(excludePatches, pp.name()))
|
||||
if (stringOps::match(excludePatches, pp.name()))
|
||||
{
|
||||
// Skip excluded patch
|
||||
continue;
|
||||
|
||||
@ -44,19 +44,14 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// Single-string matches:
|
||||
|
||||
//- Return true if text matches one of the regular expressions
|
||||
// The primary purpose of this function is to automatically convert
|
||||
// a wordReList to a wordRes for matching.
|
||||
//- Single-string match for one of the regular expressions
|
||||
// \deprecated use stringOps::match instead (deprecated NOV-2017)
|
||||
inline bool findStrings(const wordRes& matcher, const std::string& text)
|
||||
{
|
||||
return matcher(text);
|
||||
}
|
||||
|
||||
|
||||
// Multi-string matches:
|
||||
|
||||
//- Extract list indices
|
||||
// The unary match predicate has the following signature:
|
||||
// \code
|
||||
|
||||
@ -42,6 +42,7 @@ SourceFiles
|
||||
#include "dictionary.H"
|
||||
#include "HashTable.H"
|
||||
#include "stringOpsSort.H"
|
||||
#include "wordRes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -61,6 +62,13 @@ namespace stringOps
|
||||
// Correctly handles nullptr.
|
||||
std::string::size_type count(const char* str, const char c);
|
||||
|
||||
//- Return true if text matches one of the regular expressions.
|
||||
// Simply forwards a wordReList to a wordRes for the matching.
|
||||
inline bool match(const wordReList& patterns, const std::string& text)
|
||||
{
|
||||
return wordRes(patterns).match(text);
|
||||
}
|
||||
|
||||
|
||||
//- Expand occurences of variables according to the mapping
|
||||
// Expansion includes:
|
||||
|
||||
@ -23,7 +23,6 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::wordRes::wordRes
|
||||
|
||||
@ -30,7 +30,7 @@ Description
|
||||
|
||||
#include "SLList.H"
|
||||
#include "Ostream.H"
|
||||
#include "stringListOps.H"
|
||||
#include "stringOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -109,21 +109,21 @@ public:
|
||||
{
|
||||
List<word> matched(SLList<T>::size());
|
||||
|
||||
label matchI = 0;
|
||||
label matchi = 0;
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
const word& name = iter().name();
|
||||
|
||||
if
|
||||
(
|
||||
findStrings(whiteLst, name)
|
||||
&& !findStrings(blackLst, name)
|
||||
stringOps::match(whiteLst, name)
|
||||
&& !stringOps::match(blackLst, name)
|
||||
)
|
||||
{
|
||||
matched[matchI++] = name;
|
||||
matched[matchi++] = name;
|
||||
}
|
||||
}
|
||||
matched.setSize(matchI);
|
||||
matched.setSize(matchi);
|
||||
|
||||
return matched;
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
#include "boundaryRegion.H"
|
||||
#include "IOMap.H"
|
||||
#include "OFstream.H"
|
||||
#include "stringListOps.H"
|
||||
#include "stringOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -109,7 +109,7 @@ Foam::Map<Foam::word> Foam::boundaryRegion::names
|
||||
"boundaryRegion_" + Foam::name(iter.key())
|
||||
);
|
||||
|
||||
if (findStrings(patterns, lookupName))
|
||||
if (stringOps::match(patterns, lookupName))
|
||||
{
|
||||
lookup.insert(iter.key(), lookupName);
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ License
|
||||
#include "IOMap.H"
|
||||
#include "OFstream.H"
|
||||
#include "wordList.H"
|
||||
#include "stringListOps.H"
|
||||
#include "stringOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -179,7 +179,7 @@ Foam::Map<Foam::word> Foam::cellTable::names
|
||||
"cellTable_" + Foam::name(iter.key())
|
||||
);
|
||||
|
||||
if (findStrings(patterns, lookupName))
|
||||
if (stringOps::match(patterns, lookupName))
|
||||
{
|
||||
lookup.insert(iter.key(), lookupName);
|
||||
}
|
||||
@ -523,7 +523,7 @@ void Foam::cellTable::combine(const dictionary& mapDict, labelList& tableIds)
|
||||
Map<word> matches;
|
||||
forAllConstIter(Map<word>, origNames, namesIter)
|
||||
{
|
||||
if (findStrings(patterns, namesIter()))
|
||||
if (stringOps::match(patterns, namesIter()))
|
||||
{
|
||||
matches.insert(namesIter.key(), namesIter());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user