|
RAVENNAKIT
|
An abstract class representing an output stream, providing all kinds of write operations. More...
#include <output_stream.hpp>
Public Types | |
| enum class | Error { failed_to_write , out_of_memory } |
Public Member Functions | |
| OutputStream ()=default | |
| virtual | ~OutputStream ()=default |
| virtual tl::expected< void, Error > | write (const uint8_t *buffer, size_t size)=0 |
| Writes data from the given buffer to the stream. | |
| tl::expected< void, Error > | write (const char *buffer, const size_t size) |
| Convenience function to write data from a char buffer to the stream. | |
| virtual tl::expected< void, Error > | set_write_position (size_t position)=0 |
| Sets the write position in the stream. | |
| virtual size_t | get_write_position ()=0 |
| virtual void | flush ()=0 |
| Flushes the stream, ensuring that all data is written to the underlying storage. | |
| template<typename Type, std::enable_if_t< std::is_trivially_copyable_v< Type >, bool > = true> | |
| tl::expected< void, Error > | write_ne (const Type value) |
| Writes a value to the 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< void, Error > | write_be (const Type value) |
| Writes a big-endian value to the stream. | |
| template<typename Type, std::enable_if_t< std::is_trivially_copyable_v< Type >, bool > = true> | |
| tl::expected< void, Error > | write_le (const Type value) |
| Writes a little-endian value to the stream. | |
| tl::expected< void, Error > | write_string (const std::string &str) |
| Writes a string to the stream. | |
| tl::expected< void, Error > | write_cstring (const char *str) |
| Writes a c-string to the stream, up to and including the null character. | |
An abstract class representing an output stream, providing all kinds of write operations.
Definition at line 37 of file output_stream.hpp.
|
strong |
| Enumerator | |
|---|---|
| failed_to_write | |
| out_of_memory | |
Definition at line 39 of file output_stream.hpp.
|
default |
|
virtualdefault |
|
pure virtual |
Flushes the stream, ensuring that all data is written to the underlying storage.
Not all streams support this operation.
Implemented in rav::ByteStream, and rav::FileOutputStream.
|
nodiscardpure virtual |
Implemented in rav::ByteStream, and rav::FileOutputStream.
|
nodiscardpure virtual |
Sets the write position in the stream.
| position | The new write position. |
Implemented in rav::ByteStream, and rav::FileOutputStream.
|
inlinenodiscard |
Convenience function to write data from a char buffer to the stream.
| buffer | The buffer to write data from. |
| size | The number of bytes to write. |
Definition at line 61 of file output_stream.hpp.
|
nodiscardpure virtual |
Writes data from the given buffer to the stream.
| buffer | The buffer to write data from. |
| size | The number of bytes to write. |
Implemented in rav::ByteStream, and rav::FileOutputStream.
|
inlinenodiscard |
Writes a big-endian value to the stream.
| Type | The type of the value to write. |
| value | The value to write. |
Definition at line 101 of file output_stream.hpp.
|
inlinenodiscard |
Writes a c-string to the stream, up to and including the null character.
If the string doesn't have a null character then the behaviour is undefined (and probably will lead to invalid memory access).
| str | The string to write. |
Definition at line 140 of file output_stream.hpp.
|
inlinenodiscard |
Writes a little-endian value to the stream.
| Type | The type of the value to write. |
| value | The value to write. |
Definition at line 112 of file output_stream.hpp.
|
inlinenodiscard |
Writes a value to the stream in native byte order (not to be confused with network-endian).
| Type | The type of the value to write. |
| value | The value to write. |
Definition at line 90 of file output_stream.hpp.
|
inlinenodiscard |
Writes a string to the stream.
The string is prefixed with its size in little-endian format.
| str | The string to write. |
Definition at line 121 of file output_stream.hpp.