I am looking for a library - or a piece-of-a-library - for printing the contents of arrays of elements of simple types to an output stream. Its basic use is debugging code which processes very large vectors (of ints, floats, doubles, chars) - I want to be able to inspect the output to figure out what's wrong, when its wrong.
The printout should basically be similar to what the od
utility does, but with a lot more bells and whistles:
- A configurable number elements per line.
- Optional row 'headers' (index of first element in row)
- Optional row Column 'header' (index delta from the base row index)
- Configurable 'adornments' - borders, spaces, coloring etc.
- Ability to only show a specified segment of the array
- Ability to lay out some header information nicely (e.g. wrap it at same length as table)
- Ability to print only a specified subrange(s) of the array (like the Print only These Pages dialog option in LibreOffice Writer / MS Word)
- Ability to display those elements (or lines) whose values match certain patterns
- Ability to account for terminal width (wrapping, auto-selecting elements per line, auto-selecting number of digits etc.)
- Relatively easy-to-use API; if I have to jump through hoops I'd probably just write it myself.
- Support for Escaping characters
- Support for multiple character sets (e.g. ASCII and UCS-16, say).
- Some kind of colorization support when printing to an actual console.
Not all of those are required, but the more of those there are, the better.
This kind of functionality seems very trivial, I'm sure it's been (re)implemented a zillion times. The question is - where?
PS - A C-language library might do but I'd rather find something C++ish.