From 14d4484faeb78e7af7031769ec8eb460c5bae62a Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Mon, 13 Nov 2017 10:37:38 +0100
Subject: [PATCH] STYLE: single-string findStrings deprecated in favour of
 stringOps::match

- reduces ambiguity between matching a list of strings and a single string.
---
 .../foamToTecplot360/foamToTecplot360.C              |  4 ++--
 .../dataConversion/foamToVTK/foamToVTK.C             |  4 ++--
 .../primitives/strings/lists/stringListOps.H         |  9 ++-------
 .../primitives/strings/stringOps/stringOps.H         |  8 ++++++++
 src/OpenFOAM/primitives/strings/wordRes/wordResI.H   |  1 -
 src/conversion/ccm/reader/ccmSolutionTable.H         | 12 ++++++------
 src/conversion/common/tables/boundaryRegion.C        |  4 ++--
 src/conversion/common/tables/cellTable.C             |  6 +++---
 8 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C
index 98f14db9182..f5b74224638 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C
@@ -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;
diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
index e84e12f118c..eb6b3b6dddc 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
@@ -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;
diff --git a/src/OpenFOAM/primitives/strings/lists/stringListOps.H b/src/OpenFOAM/primitives/strings/lists/stringListOps.H
index 0ea3266d3ea..b87f1bd59c2 100644
--- a/src/OpenFOAM/primitives/strings/lists/stringListOps.H
+++ b/src/OpenFOAM/primitives/strings/lists/stringListOps.H
@@ -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
diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.H b/src/OpenFOAM/primitives/strings/stringOps/stringOps.H
index 3ae8bf4f4f3..7146891d37b 100644
--- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.H
+++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.H
@@ -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:
diff --git a/src/OpenFOAM/primitives/strings/wordRes/wordResI.H b/src/OpenFOAM/primitives/strings/wordRes/wordResI.H
index 600c228340d..504c0642b48 100644
--- a/src/OpenFOAM/primitives/strings/wordRes/wordResI.H
+++ b/src/OpenFOAM/primitives/strings/wordRes/wordResI.H
@@ -23,7 +23,6 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 inline Foam::wordRes::wordRes
diff --git a/src/conversion/ccm/reader/ccmSolutionTable.H b/src/conversion/ccm/reader/ccmSolutionTable.H
index cf954872e53..a2d740c8a0e 100644
--- a/src/conversion/ccm/reader/ccmSolutionTable.H
+++ b/src/conversion/ccm/reader/ccmSolutionTable.H
@@ -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;
         }
diff --git a/src/conversion/common/tables/boundaryRegion.C b/src/conversion/common/tables/boundaryRegion.C
index 12930ef06f3..a6ff68b1e0e 100644
--- a/src/conversion/common/tables/boundaryRegion.C
+++ b/src/conversion/common/tables/boundaryRegion.C
@@ -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);
         }
diff --git a/src/conversion/common/tables/cellTable.C b/src/conversion/common/tables/cellTable.C
index 5d9e137caba..6478f499120 100644
--- a/src/conversion/common/tables/cellTable.C
+++ b/src/conversion/common/tables/cellTable.C
@@ -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());
             }
-- 
GitLab