Add custom streambuf for indented output. (#391)
These classes aim to provide an alternative to `TextBuffer` in `modcc` printers. * Implement a streambuf wrapper `prefixbuf` that prepends a prefix string to each line. * Adds stream manipulators `setprefix`, `indent`, `popindent`, `settab` for manipulating the prefix in a `prefixbuf`. * Provide a wrapper stream `pfxstringstream` around `std::stringbuf` with `std::ostringstream` semantics. As implemented, a prefix string set with the `setprefix` is applied to the underlying streambuf, and is not a property of the stream. This behaviour may be surprising, so consider storing this prefix with the stream as a possible enhancement.
Showing
- src/CMakeLists.txt 1 addition, 0 deletionssrc/CMakeLists.txt
- src/util/prefixbuf.cpp 144 additions, 0 deletionssrc/util/prefixbuf.cpp
- src/util/prefixbuf.hpp 135 additions, 0 deletionssrc/util/prefixbuf.hpp
- tests/unit/CMakeLists.txt 1 addition, 0 deletionstests/unit/CMakeLists.txt
- tests/unit/test_prefixbuf.cpp 169 additions, 0 deletionstests/unit/test_prefixbuf.cpp
Please register or sign in to comment