A "pretty printer" for most SeqAn data structures and related types. More...
#include <seqan3/io/stream/debug_stream.hpp>
Public Member Functions | |
Constructor, destructor and assignment. | |
The standard functions are explicitly defaulted. | |
debug_stream_type ()=default | |
debug_stream_type (debug_stream_type const &)=default | |
debug_stream_type (debug_stream_type &&)=default | |
debug_stream_type & | operator= (debug_stream_type const &)=default |
debug_stream_type & | operator= (debug_stream_type &&)=default |
~debug_stream_type ()=default | |
constexpr | debug_stream_type (std::ostream &out) |
Construction from an output stream. | |
Miscelleneous | |
void | set_underlying_stream (std::ostream &out) |
Change the underlying output stream. More... | |
Formatted output | |
template<typename t > | |
debug_stream_type & | operator<< (t &&v) |
Forwards to the underlying stream object. | |
debug_stream_type & | operator<< (std::ostream &(*fp)(std::ostream &)) |
This overloads enables forwarding std::endl and other manipulators. | |
Format flags (std::ios_base::fmtflags) | |
std::ios_base::fmtflags that modify the stream's behaviour. | |
std::ios_base::fmtflags | flags () const |
Retrieve the format flags from the stream. | |
std::ios_base::fmtflags | flags (std::ios_base::fmtflags const flgs) |
Replace the current flags on the stream with the given argument. | |
void | setf (std::ios_base::fmtflags const flag) |
Set the format flag(s) on the stream (current flags are ORed with the argument). | |
void | unsetf (std::ios_base::fmtflags const flag) |
Unset the format flag(s) on the stream. | |
debug_stream_type & | operator<< (std::ios_base::fmtflags const flag) |
Set the format flag(s) on the stream (current flags are ORed with the argument). | |
Format flags (seqan3::fmtflags2) | |
SeqAn specific debug flags for the debug stream. | |
fmtflags2 | flags2 () const |
Retrieve the format flags from the stream. | |
fmtflags2 | flags2 (fmtflags2 flgs) |
Replace the current flags on the stream with the given argument. | |
void | setf (fmtflags2 const flag) |
Set the format flag(s) on the stream (current flags are ORed with the argument). | |
void | unsetf (fmtflags2 const flag) |
Unset the format flag(s) on the stream. | |
debug_stream_type & | operator<< (fmtflags2 const flag) |
Set the format flag(s) on the stream (current flags are ORed with the argument). | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename tuple_t > | |
debug_stream_type & | operator<< (debug_stream_type &s, tuple_t &&t) |
All tuples can be printed by printing their elements separately. More... | |
template<std::ranges::InputRange rng_t> | |
debug_stream_type & | operator<< (debug_stream_type &s, rng_t &&r) |
All input ranges can be printed to the seqan3::debug_stream element-wise (if their elements are printable). More... | |
Formatted output overloads | |
template<alphabet_concept alphabet_t> | |
debug_stream_type & | operator<< (debug_stream_type &s, alphabet_t const l) |
All alphabets can be printed to the seqan3::debug_stream by their char representation. More... | |
A "pretty printer" for most SeqAn data structures and related types.
A global instance of this type exists as seqan3::debug_stream. You can stream to it as you would to std::cout or std::cerr, but the debug stream has special overloads that make certain types streamable (that are not streamable to std::cout). Additionally some data structures are visualised more elaborately via the debug stream and there are extra flags to configure it (seqan3::fmtflags2).
Simple usage:
Changing flags:
See seqan3::fmtflags2 for more details.
|
inline |
Change the underlying output stream.
out | Reference to the new output stream. |
The actual underlying stream that is printed to defaults to std::cerr, but can be changed via this function. You can set any kind of output stream, e.g. a std::ostringstream or a std::ofstream if you want to write to a file, but please be aware that the debug_stream never takes ownership of the underlying stream so you need to take special care that its object lifetime does not end before the debug_stream's.
In the case where you wish to print to some stream object locally, instead create you own debug stream:
|
related |
All alphabets can be printed to the seqan3::debug_stream by their char representation.
alphabet_t | Type of the alphabet to be printed; must model seqan3::alphabet_concept. |
s | The seqan3::debug_stream. |
l | The alphabet letter. |
|
related |
All tuples can be printed by printing their elements separately.
tuple_t | Type of the tuple to be printed; must model seqan3::tuple_like_concept. |
s | The seqan3::debug_stream. |
t | The tuple. |
|
related |
All input ranges can be printed to the seqan3::debug_stream element-wise (if their elements are printable).
rng_t | Type of the range to be printed; must model std::ranges::InputRange. |
s | The seqan3::debug_stream. |
r | The input range. |
If the element type models seqan3::alphabet_concept (and is not an unsigned integer), the range is printed just as if it were a string, i.e. std::vector<dna4>{'C'_dna4, 'G'_dna4, 'A'_dna4}
is printed as "CGA".
In all other cases the elements are comma separated and the range is enclosed in brackets, i.e. std::vector<int>{3, 1, 33, 7}
is printed as "[3,1,33,7]".