ENH: improvements to stringOps format and split functions

- split now optionally retains empty substrings.
  Added split on fixed field width.

- Foam::name() now formats directly into string buffer, which a
  removes one layer of copying and also avoids using a non-constexpr
  in the temporary.

STYLE: explicit type narrowing on zero-padded output for ensight
This commit is contained in:
Mark Olesen
2017-11-23 20:17:33 +01:00
parent 6e8586df5d
commit d49929b210
5 changed files with 170 additions and 42 deletions

View File

@ -62,6 +62,18 @@ int main(int argc, char *argv[])
dict.add("FOAM_RUN", subDict);
// Test Foam::name with formatting string
{
word formatted = Foam::name("formatted=<%X>", 0xdeadbeef);
Info<<"formatted: " << formatted << nl;
}
Info<<"formatted: "
<< Foam::name("formatted not checked for validity=<%X>", 0xdeadbeef)
<< nl
<< endl
Info<< "string:" << test << nl << "hash:"
<< unsigned(string::hash()(test)) << endl;