Commit Graph

12 Commits

Author SHA1 Message Date
fbdd16a293 ENH: add stringOps::splitAny, stringOps::splitSpace
- assists when building simple hand-rolled parsers.
  Also add string::split() taking a sub-string for the delimiter.
2017-08-14 10:36:12 +02:00
910967c070 ENH: add Foam::SubStrings container and stringOps::split
- generic means of holding ranges of substring iterators
2017-07-20 19:53:57 +02:00
9810c68e76 ENH: support default/alternate values for env-vars in dictionary lookup
- was previously only within string expansions, but cover dictionaries
  as well for consistency

ENH: replace the never-used fileName::caseName() functionality

- stringOps::inplaceReplaceVar() is more general

     stringOps::inplaceReplaceVar(myfile, "FOAM_CASE");

STYLE: relax parameter passing when calling some POSIX 'query' functions.

- A std::string is sufficient since the functions use a plain C-string.
  Eg, getEnv("SOMETHING").
  Retain more stringent Foam::word for things like setEnv, since this
  could be useful.
2017-02-24 17:37:48 +01:00
cae7ce37f5 ENH: provide formatting version of Foam::name() (issue #253)
- there are some cases in which the C-style sprintf is much more
  convenient, albeit problematic for buffer overwrites.

  Provide a formatting version of Foam::name() for language
  primitives that is buffer-safe.

  Returns a Foam::word, so that further output will be unquoted, but
  without any checking that the characters are indeed entirely valid
  word characters.

  Example use,
      i = 1234;
      s = Foam::name("%08d", i);
      produces '00001234'

  Alternative using string streams:

      std::ostringstream buf;
      buf.fill('0');
      buf << setw(8) << i;
      s = buf.str();

  Note that the format specification can also be slightly more complex:

     Foam::name("output%08d.vtk", i);
     Foam::name("timing=%.2fs", time);

It remains the caller's responsibility to ensure that the format mask
is valid.
2016-07-01 08:23:13 +02:00
f17c43948b ENH: #include: allow recursive substitution 2012-10-12 17:37:38 +01:00
c2dd153a14 Copyright transfered to the OpenFOAM Foundation 2011-08-14 12:17:30 +01:00
2a925aeff3 ENH: support alternative values in string expansion
- syntax as per Bourne/Korn shell
      ${parameter:+altValue}

  If parameter is unset or null, nothing is substituted.
  Otherwise the \c altValue is substituted.
2011-03-18 10:12:38 +01:00
3b72fc3e38 ENH: support default values in string expansion
- syntax as per Bourne/Korn shell
      ${parameter:-defValue}

  If parameter is unset or null, the \c defValue is substituted.
  Otherwise, the value of parameter is substituted.
2011-03-02 14:11:30 +01:00
97a15a8b06 STYLE: simplify stringOps::expand names 2011-02-23 14:42:51 +01:00
31f6d9ba5e ENH: add stringOps::expandDict 2011-02-23 13:38:57 +01:00
23dd3e072b ENH: provide for writing contents only from dictionary entries 2011-02-23 13:02:36 +01:00
ba873744f3 ENH: add stringOps namespace with a collection of string-related ops 2011-02-22 10:20:55 +01:00