ENH: provide word::validated() static method

- Constructs a validated word, in which all invalid characters have
  been stripped out and any leading digit is '_'-prefixed.
  Words with leading digits cause parse issues when read back later.

- Replaces previous functionally identical code from src/conversion

--
COMP: test against nullObject instead of checking address for null pointer.
This commit is contained in:
Mark Olesen
2017-02-03 15:13:13 +00:00
parent f532a99dc3
commit 9f91084eef
10 changed files with 114 additions and 201 deletions

View File

@ -69,6 +69,13 @@ int main(int argc, char *argv[])
Info<<"trimRight: " << stringOps::trimRight(test) << endl;
Info<<"trim: " << stringOps::trim(test) << endl;
Info<< nl;
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<< nl;
// test sub-strings via iterators
string::const_iterator iter = test.end();