class
#include <core/memory/standard_stream.hpp>
StandardStream Stream implementation which wraps a libc
file pointer.
Base classes
- class Stream
- Interface class for memory streams. Abstracts away sources or destinations of data.
Constructors, destructors, conversion operators
- StandardStream(FILE* file, bool close = false)
- Constructs.
- StandardStream(StandardStream&& other) noexcept
- Move constructs.
Public functions
- auto read(void* data, std::size_t size) -> std::size_t override
- Reads data from the stream.
- auto write(const void* data, std::size_t size) -> std::size_t override
- Writes data to the stream.
- auto tell() const -> std::size_t override
- Gets the current position in the stream.
- void seek(ptrdiff_t offset, SeekOrigin origin) override
- Seeks to a position in the stream.
- auto eof() const -> bool override
- Checks if the stream still has content to read.
- auto peek() -> char override
- Peeks one byte from the stream.
Function documentation
cubos:: core:: memory:: StandardStream:: StandardStream(FILE* file,
bool close = false)
Constructs.
Parameters | |
---|---|
file | File to read/write from. |
close | Should the file be closed when this stream is destructed? |
cubos:: core:: memory:: StandardStream:: StandardStream(StandardStream&& other) noexcept
Move constructs.
Parameters | |
---|---|
other | Moved stream. |
std::size_t cubos:: core:: memory:: StandardStream:: read(void* data,
std::size_t size) override
Reads data from the stream.
Parameters | |
---|---|
data | Buffer to read data into. |
size | Size of the buffer. |
Returns | Number of bytes read. |
std::size_t cubos:: core:: memory:: StandardStream:: write(const void* data,
std::size_t size) override
Writes data to the stream.
Parameters | |
---|---|
data | Buffer to write data from. |
size | Size of the buffer. |
Returns | Number of bytes written. |
std::size_t cubos:: core:: memory:: StandardStream:: tell() const override
Gets the current position in the stream.
Returns | Current position in the stream, or SIZE_MAX if the position is unknown. |
---|
void cubos:: core:: memory:: StandardStream:: seek(ptrdiff_t offset,
SeekOrigin origin) override
Seeks to a position in the stream.
Parameters | |
---|---|
offset | Offset to seek to. |
origin | Origin of the offset. |
bool cubos:: core:: memory:: StandardStream:: eof() const override
Checks if the stream still has content to read.
Returns | Whether the stream has reached the end. |
---|
char cubos:: core:: memory:: StandardStream:: peek() override
Peeks one byte from the stream.
Returns | Peeked byte. |
---|