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

@ -59,7 +59,7 @@ Foam::word Foam::ensightCase::options::padded(const label i) const
// As per Foam::name, but with fixed length
char buf[32];
::snprintf(buf, 32, printf_.c_str(), i);
::snprintf(buf, 32, printf_.c_str(), static_cast<int>(i));
buf[31] = 0;
// no stripping required