Abstract base class for sequential byte streams (read/write).
More...
#include <Stream.h>
|
| virtual | ~Stream ()=default |
| |
| virtual uint64_t | GetLength ()=0 |
| | Returns the total length of the stream in bytes.
|
| |
| uint64_t | GetBaseAddress () |
| | Returns the current stream position as an absolute byte offset.
|
| |
| virtual void | Seek (int32_t offset, SeekOffsetType seekType)=0 |
| | Moves the stream position.
|
| |
| virtual std::unique_ptr< char[]> | Read (size_t length)=0 |
| | Reads length bytes from the current position and advances the position.
|
| |
| virtual void | Read (char *dest, size_t length)=0 |
| | Reads length bytes from the current position into a caller-supplied buffer.
|
| |
| virtual int8_t | ReadByte ()=0 |
| | Reads a single byte from the current position.
|
| |
| virtual void | Write (char *destBuffer, size_t length)=0 |
| | Writes length bytes from destBuffer at the current position.
|
| |
| virtual void | WriteByte (int8_t value)=0 |
| | Writes a single byte at the current position.
|
| |
| virtual std::vector< char > | ToVector ()=0 |
| | Returns the full stream contents as a std::vector<char>.
|
| |
| virtual void | Flush ()=0 |
| | Flushes any buffered writes to the underlying storage.
|
| |
| virtual void | Close ()=0 |
| | Closes the stream and releases any held resources.
|
| |
|
| uint64_t | mBaseAddress |
| | Current read/write position (byte offset from the start).
|
| |
Abstract base class for sequential byte streams (read/write).
Stream provides a common interface used by BinaryReader and BinaryWriter so that both can operate transparently over an in-memory buffer (MemoryStream) or any other concrete stream implementation without code changes.
All read and write operations advance an internal position cursor. Seeking is supported via Seek() with relative or absolute offsets.
◆ ~Stream()
| virtual Ship::Stream::~Stream |
( |
| ) |
|
|
virtualdefault |
◆ Close()
| virtual void Ship::Stream::Close |
( |
| ) |
|
|
pure virtual |
◆ Flush()
| virtual void Ship::Stream::Flush |
( |
| ) |
|
|
pure virtual |
◆ GetBaseAddress()
| uint64_t Ship::Stream::GetBaseAddress |
( |
| ) |
|
Returns the current stream position as an absolute byte offset.
◆ GetLength()
| virtual uint64_t Ship::Stream::GetLength |
( |
| ) |
|
|
pure virtual |
◆ Read() [1/2]
| virtual void Ship::Stream::Read |
( |
char * |
dest, |
|
|
size_t |
length |
|
) |
| |
|
pure virtual |
Reads length bytes from the current position into a caller-supplied buffer.
- Parameters
-
| dest | Writable destination buffer (must be at least length bytes). |
| length | Number of bytes to read. |
Implemented in Ship::MemoryStream.
◆ Read() [2/2]
| virtual std::unique_ptr< char[]> Ship::Stream::Read |
( |
size_t |
length | ) |
|
|
pure virtual |
Reads length bytes from the current position and advances the position.
- Parameters
-
| length | Number of bytes to read. |
- Returns
- Heap-allocated buffer containing the read bytes.
Implemented in Ship::MemoryStream.
◆ ReadByte()
| virtual int8_t Ship::Stream::ReadByte |
( |
| ) |
|
|
pure virtual |
Reads a single byte from the current position.
Throws std::out_of_range if the position is past the end of the stream.
- Returns
- The byte value at the current position.
Implemented in Ship::MemoryStream.
◆ Seek()
| virtual void Ship::Stream::Seek |
( |
int32_t |
offset, |
|
|
SeekOffsetType |
seekType |
|
) |
| |
|
pure virtual |
Moves the stream position.
- Parameters
-
| offset | Number of bytes to seek (can be negative for SeekOffsetType::Current/End). |
| seekType | Reference point for the seek (start, current, or end). |
Implemented in Ship::MemoryStream.
◆ ToVector()
| virtual std::vector< char > Ship::Stream::ToVector |
( |
| ) |
|
|
pure virtual |
Returns the full stream contents as a std::vector<char>.
Implemented in Ship::MemoryStream.
◆ Write()
| virtual void Ship::Stream::Write |
( |
char * |
destBuffer, |
|
|
size_t |
length |
|
) |
| |
|
pure virtual |
Writes length bytes from destBuffer at the current position.
- Parameters
-
| destBuffer | Source buffer. |
| length | Number of bytes to write. |
Implemented in Ship::MemoryStream.
◆ WriteByte()
| virtual void Ship::Stream::WriteByte |
( |
int8_t |
value | ) |
|
|
pure virtual |
Writes a single byte at the current position.
- Parameters
-
Implemented in Ship::MemoryStream.
◆ mBaseAddress
| uint64_t Ship::Stream::mBaseAddress |
|
protected |
Current read/write position (byte offset from the start).
The documentation for this class was generated from the following file: