SeqAn3 3.4.0-rc.4
The Modern C++ library for sequence analysis.
|
Functionally the same as std::ostreambuf_iterator, but offers writing a range more efficiently. More...
#include <seqan3/io/stream/detail/fast_ostreambuf_iterator.hpp>
Public Types | |
Associated types | |
using | difference_type = ptrdiff_t |
Defaults to ptrdiff_t. | |
using | value_type = char_t |
The char type of the stream. | |
using | reference = char_t |
The char type of the stream. | |
using | pointer = void |
Has no pointer type. | |
using | iterator_category = std::output_iterator_tag |
Public Member Functions | |
bool | failed () const noexcept |
Returns true if this iterator has encountered the end-of-file condition on output, false` otherwise. | |
fast_ostreambuf_iterator & | operator* () |
no op. | |
fast_ostreambuf_iterator & | operator= (char_t const c) |
Writes a character to the associated output stream. | |
void | write_end_of_line (bool const add_cr) |
Write "\n" or "\r\n" to the stream buffer, depending on arguments. | |
template<typename number_type > requires std::is_arithmetic_v<number_type> | |
auto | write_number (number_type num) |
Writes a number to the underlying stream buffer using std::to_chars. | |
template<std::ranges::forward_range range_type> requires std::ranges::borrowed_range<range_type> | |
auto | write_range (range_type &&rng) |
Writes a range to the associated output. | |
Constructors, destructor and assignment | |
fast_ostreambuf_iterator () noexcept=default | |
Defaulted. | |
fast_ostreambuf_iterator (fast_ostreambuf_iterator const &) noexcept=default | |
Defaulted. | |
fast_ostreambuf_iterator (fast_ostreambuf_iterator &&) noexcept=default | |
Defaulted. | |
fast_ostreambuf_iterator & | operator= (fast_ostreambuf_iterator const &) noexcept=default |
Defaulted. | |
fast_ostreambuf_iterator & | operator= (fast_ostreambuf_iterator &&) noexcept=default |
Defaulted. | |
~fast_ostreambuf_iterator () noexcept=default | |
Defaulted. | |
fast_ostreambuf_iterator (std::basic_streambuf< char_t, traits_t > &ibuf) | |
Construct from a stream buffer. | |
Arithmetic operators | |
fast_ostreambuf_iterator & | operator++ () |
no op. | |
fast_ostreambuf_iterator & | operator++ (int) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Private Attributes | |
stream_buffer_exposer< char_t, traits_t > * | stream_buf = nullptr |
Down-cast pointer to the stream-buffer. | |
Functionally the same as std::ostreambuf_iterator, but offers writing a range more efficiently.
char_t | The stream's character type. |
traits_t | The stream's traits type. |
The functions seqan3::fast_ostreambuf_iterator::write_range and seqan3::fast_ostreambuf_iterator::write_n allow more efficient writing of ranges by writing in chunks that avoiding overflow checks.
| no-api |
Pure output iterator.
|
no-apiinline |
Writes a number to the underlying stream buffer using std::to_chars.
number_type | The type of number; must model seqan3::arithmetic. |
[in] | num | The number to write. |
|
no-apiinline |
Writes a range to the associated output.
range_type | The type of range to write; Must model std::ranges::forward_range. |
[in] | rng | The range to write. |
range_type
models std::ranges::borrowed_range
returns an iterator pointing to end of the range (rng) else returns void
.This function avoids the buffer-at-end check by writing the range in chunks, where a chunks has the size of the remaining space in the put area of the buffer. If the range type models std::ranges::sized_range
the chunks are written using std::ranges::copy_n
, which may use memcpy if applicable. Otherwise, a simple for loop iterates over the chunk.
std::ranges::borrowed_range
.Example: