template<class StreamBase, template<class> class StreamErased>
binary_io::components::any_stream_base class

Implements the common interface of every any_stream.

Constructors, destructors, conversion operators

any_stream_base() defaulted
Constructs the stream without any active underlying stream.
template<class S>
any_stream_base(const S& a_stream)
Uses the given stream as the active underlying stream.
template<class S>
any_stream_base(S&& a_stream)
Uses the given stream as the active underlying stream.

Buffering

void flush() noexcept
Flushes the underlying stream's buffers, if applicable.

Modifiers

template<class S, class... Args>
any_stream_base(std::in_place_type_t<S>, Args && ... a_args)
Constructs the given underlying stream in-place, using the given arguments.
template<class S, class... Args>
void emplace(Args && ... a_args)
Constructs the given underlying stream in-place, using the given arguments.
void reset() noexcept
Destroys the underlying buffer, if there is any.

Observers

template<class S>
auto get() -> S&
Attempts to get the underlying stream as the given type.
template<class S>
auto get() const -> const S&
Attempts to get the underlying stream as the given type.
template<class S>
auto get_if() -> S* noexcept
Attempts to get the underlying stream as the given type.
template<class S>
auto get_if() const -> const S* noexcept
Attempts to get the underlying stream as the given type.
auto has_value() const -> bool noexcept
Checks if there is an active underlying buffer.

Position

void seek_absolute(binary_io::streamoff a_pos) noexcept
Seek to an absolute position in the stream (i.e. from the beginning).
void seek_relative(binary_io::streamoff a_off) noexcept
Seek to a position in the stream relative to the current position.
auto tell() const -> binary_io::streamoff noexcept
Gets the current stream position.

Function documentation

template<class StreamBase, template<class> class StreamErased>
template<class S>
binary_io::components::any_stream_base<StreamBase, StreamErased>::any_stream_base(const S& a_stream)

Uses the given stream as the active underlying stream.

Parameters
a_stream The underlying stream to copy from.

template<class StreamBase, template<class> class StreamErased>
template<class S>
binary_io::components::any_stream_base<StreamBase, StreamErased>::any_stream_base(S&& a_stream)

Uses the given stream as the active underlying stream.

Parameters
a_stream The underlying stream to move from.

template<class StreamBase, template<class> class StreamErased>
void binary_io::components::any_stream_base<StreamBase, StreamErased>::flush() noexcept

Flushes the underlying stream's buffers, if applicable.

template<class StreamBase, template<class> class StreamErased>
template<class S, class... Args>
binary_io::components::any_stream_base<StreamBase, StreamErased>::any_stream_base(std::in_place_type_t<S>, Args && ... a_args)

Constructs the given underlying stream in-place, using the given arguments.

Template parameters
S The stream to construct in-place.
Args The arg types.
Parameters
a_args The arguments to use to construct the underlying stream in-place.

template<class StreamBase, template<class> class StreamErased>
template<class S, class... Args>
void binary_io::components::any_stream_base<StreamBase, StreamErased>::emplace(Args && ... a_args)

Constructs the given underlying stream in-place, using the given arguments.

Template parameters
S The stream to construct in-place.
Args The arg types.
Parameters
a_args The arguments to use to construct the underlying stream in-place.

template<class StreamBase, template<class> class StreamErased>
void binary_io::components::any_stream_base<StreamBase, StreamErased>::reset() noexcept

Destroys the underlying buffer, if there is any.

template<class StreamBase, template<class> class StreamErased>
template<class S>
S& binary_io::components::any_stream_base<StreamBase, StreamErased>::get()

Attempts to get the underlying stream as the given type.

Template parameters
S The type to attempt to cast to the underlying stream to.
Returns The underlying stream.
Exceptions
std::bad_cast Thrown if the underlying stream is _not_ of the given type.

template<class StreamBase, template<class> class StreamErased>
template<class S>
const S& binary_io::components::any_stream_base<StreamBase, StreamErased>::get() const

Attempts to get the underlying stream as the given type.

Template parameters
S The type to attempt to cast to the underlying stream to.
Returns The underlying stream.
Exceptions
std::bad_cast Thrown if the underlying stream is _not_ of the given type.

template<class StreamBase, template<class> class StreamErased>
template<class S>
S* binary_io::components::any_stream_base<StreamBase, StreamErased>::get_if() noexcept

Attempts to get the underlying stream as the given type.

Template parameters
S The type to attempt to cast to the underlying stream to.
Returns The underlying stream.

template<class StreamBase, template<class> class StreamErased>
template<class S>
const S* binary_io::components::any_stream_base<StreamBase, StreamErased>::get_if() const noexcept

Attempts to get the underlying stream as the given type.

Template parameters
S The type to attempt to cast to the underlying stream to.
Returns The underlying stream.

template<class StreamBase, template<class> class StreamErased>
bool binary_io::components::any_stream_base<StreamBase, StreamErased>::has_value() const noexcept

Checks if there is an active underlying buffer.

Returns true if there is an active underlying buffer, false otherwise.

template<class StreamBase, template<class> class StreamErased>
void binary_io::components::any_stream_base<StreamBase, StreamErased>::seek_absolute(binary_io::streamoff a_pos) noexcept

Seek to an absolute position in the stream (i.e. from the beginning).

Parameters
a_pos The absolute position to seek to.

template<class StreamBase, template<class> class StreamErased>
void binary_io::components::any_stream_base<StreamBase, StreamErased>::seek_relative(binary_io::streamoff a_off) noexcept

Seek to a position in the stream relative to the current position.

Parameters
a_off The offset to seek to.

template<class StreamBase, template<class> class StreamErased>
binary_io::streamoff binary_io::components::any_stream_base<StreamBase, StreamErased>::tell() const noexcept

Gets the current stream position.

Returns The current stream position.