STYLE: word::validated without underscore prefix by default (issue #518)

- this now appears to be the more common use case.
This commit is contained in:
Mark Olesen
2017-07-18 14:09:49 +02:00
parent 2c69b7d7c4
commit 72f242405a
5 changed files with 11 additions and 10 deletions

View File

@ -83,7 +83,8 @@ int main(int argc, char *argv[])
Info<<"camel-case => " << (word("camel") & "case") << nl; Info<<"camel-case => " << (word("camel") & "case") << nl;
for (const auto& s : { " text with \"spaces'", "08/15 value" }) 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; Info<< nl;

View File

@ -113,9 +113,9 @@ public:
inline static bool valid(char c); inline static bool valid(char c);
//- Construct a validated word, in which all invalid characters have //- 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. // 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 // File-like functions

View File

@ -365,7 +365,7 @@ void Foam::ccm::reader::readProblemDescription_boundaryRegion
} }
else 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()) 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); 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()) if (!str.empty())
{ {
dict.add(opt, word::validated(str)); dict.add(opt, word::validated(str, true));
} }
} }

View File

@ -155,7 +155,7 @@ void Foam::fileFormats::FIREMeshReader::readSelections(ISstream& is)
// index starting at 1 // index starting at 1
const label selId = ++nCellSelections; const label selId = ++nCellSelections;
cellTable_.setName(selId, word::validated(name)); cellTable_.setName(selId, word::validated(name, true));
cellTable_.setMaterial(selId, "fluid"); cellTable_.setMaterial(selId, "fluid");
for (label i = 0; i < count; ++i) for (label i = 0; i < count; ++i)
@ -170,7 +170,7 @@ void Foam::fileFormats::FIREMeshReader::readSelections(ISstream& is)
// index starting at 0 // index starting at 0
const label selId = nFaceSelections++; const label selId = nFaceSelections++;
faceNames.append(word::validated(name)); faceNames.append(word::validated(name, true));
for (label i = 0; i < count; ++i) for (label i = 0; i < count; ++i)
{ {

View File

@ -64,7 +64,7 @@ Foam::fileFormats::STARCDsurfaceFormatCore::readInpCellTable
if (ctnameRE.match(line, groups)) if (ctnameRE.match(line, groups))
{ {
const label tableId = atoi(groups[0].c_str()); 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()) if (!tableName.empty())
{ {