diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C index 7e09194c3797fa944fd52c281e72af779ba2e6c1..398351e3f803c8eaf20b38e5b38b71feecad6421 100644 --- a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C +++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C @@ -68,9 +68,11 @@ namespace Foam return Hash<face>::operator()(t, 0); } } + const string SEPARATOR(" -1"); -bool isSeparator(const string& line) + +bool isSeparator(const std::string& line) { return line.substr(0, 6) == SEPARATOR; } @@ -100,7 +102,7 @@ label readTag(IFstream& is) } while (tag == SEPARATOR); - return readLabel(IStringStream(tag)()); + return readLabel(tag); } @@ -144,14 +146,14 @@ void skipSection(IFstream& is) } -scalar readUnvScalar(const string& unvString) +scalar readUnvScalar(const std::string& unvString) { string s(unvString); s.replaceAll("d", "E"); s.replaceAll("D", "E"); - return readScalar(IStringStream(s)()); + return readScalar(s); } @@ -170,13 +172,13 @@ void readUnits string line; is.getLine(line); - label l = readLabel(IStringStream(line.substr(0, 10))()); + label l = readLabel(line.substr(0, 10)); Info<< "l:" << l << endl; string units(line.substr(10, 20)); Info<< "units:" << units << endl; - label unitType = readLabel(IStringStream(line.substr(30, 10))()); + label unitType = readLabel(line.substr(30, 10)); Info<< "unitType:" << unitType << endl; // Read lengthscales @@ -215,7 +217,7 @@ void readPoints string line; is.getLine(line); - label pointi = readLabel(IStringStream(line.substr(0, 10))()); + label pointi = readLabel(line.substr(0, 10)); if (pointi == -1) { diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C index 98f14db9182f3f8cd03a27ec2d6f6c1860573f09..f5b742246383603a9af56c12606f14c48216bcd8 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 e84e12f118c18ca7f1c33c478b46546de0b44651..eb6b3b6dddcac13bc22cdbbe154b58f4fb69965c 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 0ea3266d3ea204820b2bdad78243ed04de3044b9..b87f1bd59c2e9dad649db17bb702f3f534a229d0 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 3ae8bf4f4f31896cf5884b5c3bb83f8aa59aff96..7146891d37ba4f82e000b1a44b562e2ff56d769b 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 600c228340d80851c6b96be1c57cde3648d387ce..504c0642b48f78fb4d0110ab2bb51a0bc9aaa75e 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 cf954872e53ba03210dfcfbc6ab09ee0d885fb85..a2d740c8a0e79f93f40bcf76616d18f7aa865f8d 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 12930ef06f35d6b4086709b46b963bd5739d4cf3..a6ff68b1e0ec9c68350e71c2cdb8432b1cc95c89 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 5d9e137caba2c3177d113e7695d97e082172f578..6478f499120c737428a00becdece135b20210c04 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()); } diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C index 6db990686d140bbd64b044b59d7cd20a933e3e3d..84fdfb1f3f78084ae5b2ae9f812ddbeea61662c3 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C @@ -70,7 +70,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated } // const scalar timeValue = Foam::name(this->mesh().time().timeValue()); - const scalar timeValue = readScalar(IStringStream(timeDir)()); + const scalar timeValue = readScalar(timeDir); OFstream osCase(baseDir/surfName + ".case"); ensightGeoFile osGeom @@ -99,9 +99,13 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated << "model: 1 " << osGeom.name().name() << nl << nl << "VARIABLE" << nl - << ensightPTraits<Type>::typeName << " per " - << word(isNodeValues ? "node:" : "element:") - << setw(3) << 1 + << ensightPTraits<Type>::typeName + << + ( + isNodeValues + ? " per node: 1 " // time-set 1 + : " per element: 1 " // time-set 1 + ) << setw(15) << varName << " " << surfName.c_str() << ".********." << varName << nl << nl @@ -175,7 +179,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated // surfName already validated const fileName meshFile(baseDir/surfName + ".000000.mesh"); - const scalar timeValue = readScalar(IStringStream(timeDir)()); + const scalar timeValue = readScalar(timeDir); label timeIndex = 0; // Do case file @@ -190,7 +194,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated if (is.good() && dict.read(is)) { dict.lookup("times") >> times; - const scalar timeValue = readScalar(IStringStream(timeDir)()); + const scalar timeValue = readScalar(timeDir); label index = findLower(times, timeValue); timeIndex = index+1; }