|
RAVENNAKIT
|
A non-owning view of some data that can be read from. More...
#include <input_stream_view.hpp>
Public Member Functions | |
| InputStreamView (const uint8_t *data, size_t size) | |
| Constructs a new input stream view pointing to the given data. | |
| template<class T> | |
| InputStreamView (const T &container) | |
| Constructs a new input stream view pointing to the given container. | |
| ~InputStreamView () override=default | |
| InputStreamView (const InputStreamView &)=default | |
| InputStreamView & | operator= (const InputStreamView &)=default |
| InputStreamView (InputStreamView &&) noexcept=default | |
| InputStreamView & | operator= (InputStreamView &&) noexcept=default |
| void | reset () |
| Resets the stream to its initial state by setting the read position to 0. | |
| tl::expected< size_t, Error > | read (uint8_t *buffer, size_t size) override |
| Reads data from the stream into the given buffer. | |
| bool | set_read_position (size_t position) override |
| Sets the read position in the stream. | |
| size_t | get_read_position () override |
| std::optional< size_t > | size () const override |
| bool | exhausted () override |
| Public Member Functions inherited from rav::InputStream | |
| InputStream ()=default | |
| virtual | ~InputStream ()=default |
| std::optional< size_t > | remaining () |
| bool | skip (size_t size) |
| Skips size amount of bytes in the stream. | |
| tl::expected< std::string, Error > | read_as_string (size_t size) |
| Reads size amount of bytes from the stream and returns it as a string. | |
| template<typename Type, std::enable_if_t< std::is_trivially_copyable_v< Type >, bool > = true> | |
| tl::expected< Type, Error > | read_ne () |
| Reads a value from the given stream in native byte order (not to be confused with network-endian). | |
| template<typename Type, std::enable_if_t< std::is_trivially_copyable_v< Type >, bool > = true> | |
| tl::expected< Type, Error > | read_be () |
| Reads a big-endian value from the given stream. | |
| template<typename Type, std::enable_if_t< std::is_trivially_copyable_v< Type >, bool > = true> | |
| tl::expected< Type, Error > | read_le () |
| Reads a little-endian value from the given stream. | |
Additional Inherited Members | |
| Public Types inherited from rav::InputStream | |
| enum class | Error { insufficient_data , failed_to_set_read_position } |
| Static Public Member Functions inherited from rav::InputStream | |
| static const char * | to_string (const Error e) |
A non-owning view of some data that can be read from.
Definition at line 34 of file input_stream_view.hpp.
| rav::InputStreamView::InputStreamView | ( | const uint8_t * | data, |
| size_t | size ) |
Constructs a new input stream view pointing to the given data.
It doesn't take ownership of the data so make sure that the data outlives the stream.
| data | The data to read from. Must not be nullptr. |
| size | The size of the data. |
|
inlineexplicit |
Constructs a new input stream view pointing to the given container.
It doesn't take ownership of the container so make sure that the container outlives the stream.
| T | The container type. |
| container | The container to read from. Must not be empty. |
Definition at line 51 of file input_stream_view.hpp.
|
overridedefault |
|
default |
|
defaultnoexcept |
|
nodiscardoverridevirtual |
Implements rav::InputStream.
|
nodiscardoverridevirtual |
Implements rav::InputStream.
|
default |
|
defaultnoexcept |
|
nodiscardoverridevirtual |
Reads data from the stream into the given buffer.
If the stream doesn't have enough data, then nothing will be read.
| buffer | The buffer to read data into. |
| size | The number of bytes to read. |
Implements rav::InputStream.
| void rav::InputStreamView::reset | ( | ) |
Resets the stream to its initial state by setting the read position to 0.
|
nodiscardoverridevirtual |
Sets the read position in the stream.
| position | The new read position. |
Implements rav::InputStream.
|
nodiscardoverridevirtual |
Implements rav::InputStream.