1. 30 Jan, 2019 1 commit
    • Mark Olesen's avatar
      ENH: minor adjustments to Switch · 40122a8f
      Mark Olesen authored
      - assignment operators return a value, for consistency with bool.
      
      - partial revert of DEFAULT_TRUE, DEFAULT_FALSE, to reduce complexity.
      40122a8f
  2. 29 Jan, 2019 1 commit
    • Mark Olesen's avatar
      ENH: add 'default' as possible Switch state, but not as input/output · fd348374
      Mark Olesen authored
      - 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)
      fd348374
  3. 23 Jan, 2019 1 commit
  4. 10 Jan, 2019 1 commit
  5. 28 Oct, 2017 1 commit
    • Mark Olesen's avatar
      ENH: add fileName::validate static method (issue #628) · 92a22882
      Mark Olesen authored
      - 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
      92a22882
  6. 25 Oct, 2017 1 commit
    • Mark Olesen's avatar
      ENH: handle underflow (rounding) of float/double as zero (issue #625) · ec92e198
      Mark Olesen authored
      - 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.
      ec92e198
  7. 12 Oct, 2017 1 commit
  8. 22 Sep, 2017 1 commit
    • Mark Olesen's avatar
      ENH: improve consistency in parsing primitives from strings (issue #590) · 41f59b07
      Mark Olesen authored
      - 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.
      41f59b07