From 72f242405a0b85286b720dada2f9818b16bdd283 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 18 Jul 2017 14:09:49 +0200 Subject: [PATCH] STYLE: word::validated without underscore prefix by default (issue #518) - this now appears to be the more common use case. --- applications/test/string/Test-string.C | 3 ++- src/OpenFOAM/primitives/strings/word/word.H | 4 ++-- src/conversion/ccm/reader/ccmReader.C | 8 ++++---- src/conversion/fire/FIREMeshReader.C | 4 ++-- .../surfaceFormats/starcd/STARCDsurfaceFormatCore.C | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/applications/test/string/Test-string.C b/applications/test/string/Test-string.C index 208e1c297f..d660a36240 100644 --- a/applications/test/string/Test-string.C +++ b/applications/test/string/Test-string.C @@ -83,7 +83,8 @@ int main(int argc, char *argv[]) Info<<"camel-case => " << (word("camel") & "case") << nl; for (const auto& s : { " text with \"spaces'", "08/15 value" }) { - Info<<"validated \"" << s << "\" => " << word::validated(s) << nl; + Info<<"validated \"" << s << "\" => " + << word::validated(s, true) << nl; } Info<< nl; diff --git a/src/OpenFOAM/primitives/strings/word/word.H b/src/OpenFOAM/primitives/strings/word/word.H index 0661255341..126d5c08c7 100644 --- a/src/OpenFOAM/primitives/strings/word/word.H +++ b/src/OpenFOAM/primitives/strings/word/word.H @@ -113,9 +113,9 @@ public: inline static bool valid(char c); //- Construct a validated word, in which all invalid characters have - // been stripped out. Normally also prefix any leading digit + // been stripped out. Optionally prefix any leading digit // with '_' to have words that work nicely as dictionary keywords. - static word validated(const std::string& s, const bool prefix=true); + static word validated(const std::string& s, const bool prefix=false); // File-like functions diff --git a/src/conversion/ccm/reader/ccmReader.C b/src/conversion/ccm/reader/ccmReader.C index 9b16f943bf..302e89981d 100644 --- a/src/conversion/ccm/reader/ccmReader.C +++ b/src/conversion/ccm/reader/ccmReader.C @@ -365,7 +365,7 @@ void Foam::ccm::reader::readProblemDescription_boundaryRegion } else { - dict.add(opt, word::validated(str)); + dict.add(opt, word::validated(str, true)); } } @@ -407,7 +407,7 @@ void Foam::ccm::reader::readProblemDescription_boundaryRegion if (!str.empty()) { - dict.add(opt, word::validated(str)); + dict.add(opt, word::validated(str, true)); } } @@ -472,7 +472,7 @@ void Foam::ccm::reader::readProblemDescription_cellTable str = "zone_" + ::Foam::name(Id); } - dict.add(opt, word::validated(str)); + dict.add(opt, word::validated(str, true)); } @@ -484,7 +484,7 @@ void Foam::ccm::reader::readProblemDescription_cellTable if (!str.empty()) { - dict.add(opt, word::validated(str)); + dict.add(opt, word::validated(str, true)); } } diff --git a/src/conversion/fire/FIREMeshReader.C b/src/conversion/fire/FIREMeshReader.C index 9202723531..df5ee05ef7 100644 --- a/src/conversion/fire/FIREMeshReader.C +++ b/src/conversion/fire/FIREMeshReader.C @@ -155,7 +155,7 @@ void Foam::fileFormats::FIREMeshReader::readSelections(ISstream& is) // index starting at 1 const label selId = ++nCellSelections; - cellTable_.setName(selId, word::validated(name)); + cellTable_.setName(selId, word::validated(name, true)); cellTable_.setMaterial(selId, "fluid"); for (label i = 0; i < count; ++i) @@ -170,7 +170,7 @@ void Foam::fileFormats::FIREMeshReader::readSelections(ISstream& is) // index starting at 0 const label selId = nFaceSelections++; - faceNames.append(word::validated(name)); + faceNames.append(word::validated(name, true)); for (label i = 0; i < count; ++i) { diff --git a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C index 71b3751c8c..7443771812 100644 --- a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C +++ b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C @@ -64,7 +64,7 @@ Foam::fileFormats::STARCDsurfaceFormatCore::readInpCellTable if (ctnameRE.match(line, groups)) { const label tableId = atoi(groups[0].c_str()); - const word tableName = word::validated(groups[1]); + const word tableName = word::validated(groups[1], true); if (!tableName.empty()) {