52 size_t psize() const noexcept;
58 pos_type
gtellp() const noexcept;
64 pos_type
ptellp() const noexcept;
96 virtual int_type
overflow(int_type c = traits_type::eof()) override;
98 virtual std::streamsize
showmanyc() override;
99 virtual int_type
pbackfail(int_type c = traits_type::eof()) override;
105 virtual
int sync() override;
119 virtual pos_type
seekoff(off_type off, std::ios_base::seekdir dir,
120 std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override;
129 virtual pos_type
seekpos(pos_type pos,
130 std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override;
140 template <typename T, std::enable_if_t<
141 std::is_unsigned_v<T>,
int> = 0
145 if (value >
static_cast<T
>(std::numeric_limits<std::make_signed_t<T>>::max()))
146 throw std::overflow_error(
"Cannot convert a value into pos_type since this would cause an overflow in circularbuf::to_pos_type().");
148 return static_cast<std::make_signed_t<T>
>(value);
Circular stream buffer to be used with the standard library's stream classes. Reading from or writing...
virtual int_type overflow(int_type c=traits_type::eof()) override
Refer to documentation of std::streambuf.
virtual pos_type seekpos(pos_type pos, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out) override
Sets the position of the pointer(s) specified by which to the absolute position pos.
bool put_overflowed
Indicates wheter an overflow occurred writing to the buffer. If this was the case,...
circularbuf(size_t size)
Constructs a new circularbuf instance with a buffer of size size. The put area will span the entire b...
pos_type gtellp() const noexcept
Indicates the get pointer's position within the get area.
virtual pos_type seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out) override
Sets the position of the pointer(s) specified by which to the position pos relative to dir....
std::streamsize avail_get_count() const noexcept
Returns the amount of characters available to be read from the current get pointer position to the ge...
void resize(size_t size)
Resizes the size of buffer to size. The put area will span the entire buffer. If the buffer is enlarg...
size_t gsize()
Returns the size of the get area. Not const since sync() needs to be called to get correct size after...
void clear()
Resets the put areas to the entire area of buffer. The get area will be empty. The get and put pointe...
virtual int_type underflow() override
Refer to documentation of std::streambuf.
virtual int_type pbackfail(int_type c=traits_type::eof()) override
Refer to documentation of std::streambuf.
size_t psize() const noexcept
Returns the size of the put area.
pos_type to_pos_type(const T value)
Converts an unsigned, integral number type to pos_type.
bool empty()
Indicates whether characters can be read from the get area. Not const since sync() needs to be called...
virtual std::streamsize showmanyc() override
Refer to documentation of std::streambuf.
pos_type ptellp() const noexcept
Indicates the put pointer's position within the put area.
char CharT
Data type of a single character stored in the buffer.
std::vector< CharT > buffer
The buffer itself.
virtual int sync() override
Expands the get area to the size of the put area. Resets put_overflowed.
DynExp's Util namespace contains commonly used functions and templates as well as extensions to Qt an...