Commit Graph

9 Commits

Author SHA1 Message Date
Mark Olesen
a341d09afc ENH: update and enhancement of memory-streams
- soft renames (ie, old names still available via typedefs) for more
  reasonable names and more coverage with std stream variants.

  The old names could be a bit cryptic.
  For example, uiliststream (== an unallocated/external list storage),
  which is written as std::ispanstream for C++23.

  Could similarly argue that IListStream is better named as
  ICharStream, since it is an input stream of characters and the
  internal storage mechanism (List or something else) is mostly
  irrelevant.

  Extending the coverage to include all std stream variants, and
  simply rewrap them for OpenFOAM IOstream types. This simplifies the
  inheritance patterns and allows reuse of icharstream/ocharstream as
  a drop-in replace for istringstream/ostringstream in other wrappers.

  Classes:
    * icharstream / ICharStream   [old: none / IListStream]
    * ocharstream / OCharStream   [old: none / OListStream]
    * ispanstream / ISpanStream   [old: uiliststream / UIListStream]
    * ospanstream / OSpanStream   [old: none / UOListStream]

  Possible new uses : read file contents into a buffer, broadcast
  buffer contents to other ranks and then transfer into an icharstream
  to be read from. This avoid the multiple intermediate copies that
  would be associated when using an istringstream.

- Use size doubling instead of block-wise incremental for ocharstream
  (OCharStream). This corresponds to the sizing behaviour as per
  std::stringstream (according to gcc-11 includes)

STYLE: drop Foam_IOstream_extras constructors for memory streams

- transitional/legacy constructors but not used in any code
2023-09-01 14:44:49 +00:00
Mark Olesen
43f8b477b7 ENH: additional ITstream access/manipulate methods
- simplifies iteration of ITstream using nRemainingTokens() and skip()
  methods or directly as a list of tokens.

  The currentToken() method returns const or non-const access to
  the token at the current tokenIndex.

  The peekToken(label) method provides failsafe read access to tokens
  at given locations.

ENH: add primitiveEntry construct with moving a single token
2023-08-16 16:22:17 +02:00
Mark Olesen
8ae2e5a969 ENH: fail-safe access of ITstream tokens as front(), back()
- more standard naming than peekFront() etc
2022-12-01 14:51:19 +00:00
Mark Olesen
7afebef509 ENH: HashTable sorted() method
- the sorted() method fills a UPtrList with sorted entries. In some
  places this can provide a more convenient means of traversing a
  HashTable in consistent order, without the extra step of creating
  a sortedToc(). The sorted() method with a UPtrList will also have
  a lower overhead than creating any sortedToc() or toc() since it is
  list of pointers and not full copies of the keys.

  Instead of this:

      HashTable<someType> table = ...;

      for (const word& key : table.sortedToc())
      {
          Info<< key << " => " << table[key] << nl;
      }

  can write this:

      for (const auto& iter : table.sorted())
      {
          Info<< iter.key() << " => " << iter.val() << nl;
      }

STYLE:

- declare hash entry key 'const' since it is immutable
2022-05-10 10:47:01 +02:00
Mark Olesen
327c43f3e8 ENH: identityOp as equivalent to std::identity (C++20)
- similar to how noOp was defined, but with perfect forwarding

STYLE: combine Swap into stdFoam

STYLE: capitalize FileOp, NegateOp template parameters
2022-03-13 22:35:18 +01:00
Mark Olesen
8884d58a52 STYLE: fix/correct some tests. Remove useless tests 2021-07-05 14:55:37 +02:00
Mark Olesen
b267f8b6da ENH: add failsafe accessors for ITstream
- failsafe examine elements: peek(), peekFirst(), peekLast()
- failsafe traversing: skip()

  For example,

      ITstream& is = dict.lookup(key);
      if (is.peek().isWord())
      {
          is.skip();
      }
2021-04-26 17:09:39 +02:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
Mark Olesen
cae8a894cd ENH: allow creation of ITstream by parsing string 2017-11-06 09:25:58 +01:00