|
BDE 4.14.0 Production release
|
Provide platform-independent stream utilities.
This component provides a namespace, bdlb::Print, containing utility functions for formatting data to bsl::ostream objects. These functions provide several variations of hexadecimal format, allow platform-independent representation of void * pointers, and can help with the indentation of hierarchical data.
This component also provides two helper classes, bdlb::PrintStringHexDumper and bdlb::PrintStringSingleLineHexDumper, that define operator<< so they can be used in chains of << operations. The bdlb::PrintStringHexDumper class produces formatted, possibly multi-line output, whereas the bdlb::PrintStringSingleLineHexDumper class produces a simple sequence of hexadecimal digits (and no newline).
The output generated by the hexDump functions is not xxd-compatible (see http://gd.tuwien.ac.at/linuxcommand.org/man_pages/xxd1.html). The following perl script is provided that will convert hexDump output into xxd-compatible form. Run the script with a file containing the hexDump output as the first argument.
This section illustrates intended use of this component.
The default output produced from pointer values is non-standard across vendor platforms. The printPtr method addresses this inconsistency by always producing a consistent format for a given pointer size:
The two helper classes allow users to stream a hexadecimal representation of a sequence of bytes into an output stream.
The bdlb::PrintStringHexDumper provides a formatted, possibly multi-line representation:
The bdlb::PrintStringSingleLineHexDumper provides a simple, single-line representation.