Commit Graph

18 Commits

Author SHA1 Message Date
Mark Olesen
3d892ace29 STYLE: set readOpt(..), writeOpt(..) by parameter, not by assignment
STYLE: qualify format/version/compression with IOstreamOption not IOstream

STYLE: reduce number of lookups when scanning {fa,fv}Solution

STYLE: call IOobject::writeEndDivider as static
2022-07-19 11:17:47 +02:00
Mark Olesen
851be8ea33 ENH: use consistent naming when toggling exception throwing on/off 2021-11-02 21:14:41 +01:00
Mark Olesen
e8cf2a2c62 ENH: more consistent use of IOstreamOption
- improves interface and data consistency.
  Older signatures are still active (via the Foam_IOstream_extras
  define).

- refine internals for IOstreamOption streamFormat, versionNumber

ENH: improve data alignment for IOstream and IOobject

- fit sizeof label/scalar into unsigned char

STYLE: remove dead code
2021-03-16 08:47:59 +00:00
Mark Olesen
1071d413a3 ENH: add ROOTGREAT constants (symmetry with ROOTSMALL)
ENH: add some scalar constants for .org compatibility (#1881)

Although it can very much be a moving target, it can prove partly
useful to have some compatibility constants/methods.

- The wholesale change of 'GREAT' -> 'great' etc (JAN-2018), makes
  user coding for multiple versions problematic. When
  COMPAT_OPENFOAM_ORG is defined, now define constants (aliases) named
  as per the openfoam.org version. Values, however, remain identical.

- For type-safe dictionary value retrieval, we have the templated
  get<> methods added around NOV-2018 and deprecated the lookupType
  method.

  The .org version followed suit in NOV-2019, but opted for renaming
  the templated lookupType method as a templated 'lookup' method.

  Using this is discouraged, but allowed when COMPAT_OPENFOAM_ORG is
  defined.
2020-10-19 21:14:17 +02:00
Mark Olesen
cb47decbf1 ENH: add Switch::negate() method (no-op for invalid state)
- flips state while preserving the textual representation.
  Eg, OFF <-> ON, YES <-> NO etc.

- fix test case to avoid triggering abort(), which we cannot try/catch
2020-10-15 17:21:33 +02:00
OpenFOAM bot
596e4aef3f STYLE: remove trailing space, tabs 2020-01-22 10:00:03 +01:00
Andrew Heather
fdf8d10ab4 Merge commit 'e9219558d7' into develop-v1906 2019-12-05 11:47:19 +00:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
Mark Olesen
c28d785a73 STYLE: adjust name, default count for readRawLabel/readRawScalar (#1378) 2019-08-06 11:54:14 +02:00
Mark Olesen
ef9bb4ae16 ENH: add low-level readRawLabels, readRawScalars (#1378)
- these use the additional byte-size checks in IOstream to handle
  native vs non-native sizes
2019-07-29 16:01:34 +02:00
Mark Olesen
3316055267 ENH: minor adjustments to Switch
- assignment operators return a value, for consistency with bool.

- partial revert of DEFAULT_TRUE, DEFAULT_FALSE, to reduce complexity.
2019-01-29 09:38:09 +01:00
Mark Olesen
a3f960e36f ENH: add 'default' as possible Switch state, but not as input/output
- in some circumstances we need to pass a bool value upwards to the
  caller and know if the true/false value was set based on real input
  or is a default value.

  Eg, in the object::read() we might normally have

     enabled_(dict.readIfPresent(key, true));

  but would lose information about why the value is true/false.

  We can change that by using

     enabled_(dict.readIfPresent<Switch>(key, Switch::DEFAULT_ON));

  After which we can use this information is testing.

      if
      (
          child.enabled().nonDefault()
        ? child.enabled()
        : parent.enabled()
      )
      { ... }

   And thus enable output if the parent requested it explicitly or by
   default and it has not been explicitly disabled in the child.

  No difference when testing as a bool and the text representation
  of DEFAULT_ON / DEFAULT_OFF will simply be "true" / "false".

ENH: add construction of Switch from dictionary (similar to Enum)
2019-01-28 23:18:21 +01:00
Mark Olesen
a5cc0ffcad STYLE: use const reference for caught exceptions 2019-01-23 09:03:06 +01:00
Mark Olesen
7720b59066 ENH: add dimensionSet provisioning for a dimensioned clip() method
- use file-local function to reduce some code clutter
2019-01-09 23:44:17 +01:00
Mark Olesen
16e75d8475 ENH: add fileName::validate static method (issue #628)
- similar to word::validate to allow stripping of invalid characters
  without triggering a FatalError.

- use this validated fileName in Foam::readDir to avoid problems when
  a directory contains files with invalid characters in their names

- adjust rmDir to handle filenames with invalid characters

- fileName::equals() static method to compare strings while ignoring
  any differences that are solely due to duplicate slashes
2017-10-26 21:23:24 +02:00
Mark Olesen
c1c4e91ffb ENH: handle underflow (rounding) of float/double as zero (issue #625)
- The problem occurs when using atof to parse values such as "1e-39"
  since this is out of range for a float and _can_ set errno to
  ERANGE.

  Similar to parsing of integers, now parse with the longest floating
  point representation "long double" via strtold (guaranteed to be
  part of C++11) and verify against the respective VGREAT values for
  overflow. Treat anything smaller than VSMALL to be zero.
2017-10-25 20:55:37 +02:00
Mark Olesen
f116217466 STYLE: remove FULLDEBUG output on readLabel, readScalar
- used in various places to test if the input can be parsed as a
  label/scalar, so warnings tend to flood the output.

- be more explicit when encountering range errors
2017-10-12 12:15:56 +02:00
Mark Olesen
accebc74ee ENH: improve consistency in parsing primitives from strings (issue #590)
- Any trailing whitespace when parsing from strings or character buffers
  is ignored rather than being treated as an error. This is consistent
  with behaviour when reading from an Istream and with leading whitespace
  being ignored in the underlying atof/atod, strtof/strtod... functions.

- Allow parsing directly from a std::string instead of just from a 'char*'.
  This reflects the C++11 addition of std::stod to complement the C
  functions strtod. This also makes it easier to parse string directly
  without using an IStringStream.

- Two-parameter parsing methods return success/failure.
  Eg,

      if (readInt32(str, &int32Val)) ...

- One-parameter parsing methods return the value on success or
  emit a FatalIOError.
  Eg,

      const char* buf;
      int32Val = readInt32(buf, &);

- Improved consistency when parsing unsigned ints.
  Use strtoimax and strtoumax throughout.

- Rename readDoubleScalar -> readDouble, readFloatScalar -> readFloat.
  Using the primitive name directly instead of the Foam typedef for
  better consistency with readInt32 etc.

- Clean/improve parseNasScalar.
  Handle normal numbers directly, reduce some operations.
2017-09-18 10:47:07 +02:00