Skip to content
Snippets Groups Projects
  • Nat Goodspeed's avatar
    066fb5da
    DRTVWR-476: Default LLSDNotationFormatter now OPTIONS_PRETTY_BINARY. · 066fb5da
    Nat Goodspeed authored
    LLSDNotationFormatter (also LLSDNotationStreamer that uses it, plus
    operator<<(std::ostream&, const LLSD&) that uses LLSDNotationStreamer) is most
    useful for displaying LLSD to a human, e.g. for logging. Having the default
    dump raw binary bytes into the log file is not only suboptimal, it can
    truncate the output if one of those bytes is '\0'. (This is a problem with the
    logging subsystem, but that's a story for another day.)
    
    Use OPTIONS_PRETTY_BINARY wherever there is a default LLSDFormatter
    ::EFormatterOptions argument.
    
    Also, allow setting LLSDFormatter subclass boolalpha(), realFormat() and
    format(options) using optional constructor arguments. Naturally, each subclass
    that supports this must accept and forward these constructor arguments to its
    LLSDFormatter base class constructor.
    
    Fix a couple bugs in LLSDNotationFormatter::format_impl() for an LLSD::Binary
    value with OPTIONS_PRETTY_BINARY:
    - The code unconditionally emitted a b(len) type prefix followed by either raw
      binary or hex, depending on the option flag. OPTIONS_PRETTY_BINARY caused it
      to emit "0x" before the hex representation of the data. This is wrong in
      that it can't be read back by either the C++ or the Python LLSD parser.
      Correct OPTIONS_PRETTY_BINARY formatting consists of b16"hex digits" rather
      than b(len)"raw bytes".
    - Although the code did set hex mode, it didn't set either the field width or
      the fill character, so that a byte value less than 16 would emit a single
      digit rather than two.
    
    Instead of having one LLSDFormatter::format() method with an optional options
    argument, declare two overloads. The format() overload without options passes
    the mOptions data member to the overload accepting options.
    
    Refactor the LLSDFormatter family, hoisting the recursive format_impl() method
    (accepting level) to a pure virtual method at LLSDFormatter base-class level.
    Most subclasses therefore need not override either base-class format() method,
    only format_impl(). In fact the short format() overload isn't even virtual.
    
    Consistently use LLSDFormatter::EFormatterOptions enum as the options
    parameter wherever such options are accepted.
    066fb5da
    History
    DRTVWR-476: Default LLSDNotationFormatter now OPTIONS_PRETTY_BINARY.
    Nat Goodspeed authored
    LLSDNotationFormatter (also LLSDNotationStreamer that uses it, plus
    operator<<(std::ostream&, const LLSD&) that uses LLSDNotationStreamer) is most
    useful for displaying LLSD to a human, e.g. for logging. Having the default
    dump raw binary bytes into the log file is not only suboptimal, it can
    truncate the output if one of those bytes is '\0'. (This is a problem with the
    logging subsystem, but that's a story for another day.)
    
    Use OPTIONS_PRETTY_BINARY wherever there is a default LLSDFormatter
    ::EFormatterOptions argument.
    
    Also, allow setting LLSDFormatter subclass boolalpha(), realFormat() and
    format(options) using optional constructor arguments. Naturally, each subclass
    that supports this must accept and forward these constructor arguments to its
    LLSDFormatter base class constructor.
    
    Fix a couple bugs in LLSDNotationFormatter::format_impl() for an LLSD::Binary
    value with OPTIONS_PRETTY_BINARY:
    - The code unconditionally emitted a b(len) type prefix followed by either raw
      binary or hex, depending on the option flag. OPTIONS_PRETTY_BINARY caused it
      to emit "0x" before the hex representation of the data. This is wrong in
      that it can't be read back by either the C++ or the Python LLSD parser.
      Correct OPTIONS_PRETTY_BINARY formatting consists of b16"hex digits" rather
      than b(len)"raw bytes".
    - Although the code did set hex mode, it didn't set either the field width or
      the fill character, so that a byte value less than 16 would emit a single
      digit rather than two.
    
    Instead of having one LLSDFormatter::format() method with an optional options
    argument, declare two overloads. The format() overload without options passes
    the mOptions data member to the overload accepting options.
    
    Refactor the LLSDFormatter family, hoisting the recursive format_impl() method
    (accepting level) to a pure virtual method at LLSDFormatter base-class level.
    Most subclasses therefore need not override either base-class format() method,
    only format_impl(). In fact the short format() overload isn't even virtual.
    
    Consistently use LLSDFormatter::EFormatterOptions enum as the options
    parameter wherever such options are accepted.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.