Stream backed by an in-memory byte buffer.
More...
#include <stream.hpp>
|
| | MemoryStream ()=default |
| | MemoryStream (std::vector< std::uint8_t > initial) |
| | Pre-fill the stream with existing bytes (copied in).
|
| StreamResult | read (std::uint8_t *buffer, std::size_t size) override |
| | Read up to size bytes into buffer.
|
| StreamResult | write (const std::uint8_t *buffer, std::size_t size) override |
| | Write up to size bytes from buffer.
|
| void | close () override |
| | Close the stream. Idempotent.
|
| bool | is_open () const override |
| | True while the stream is usable for read/write.
|
| const std::vector< std::uint8_t > & | buffer () const |
| | Byte content currently in the stream (for inspection in tests).
|
| void | rewind () |
| | Reset the read cursor to the start.
|
| void | clear () |
| | Clear all data and rewind.
|
| std::size_t | size () const |
| std::size_t | read_position () const |
Stream backed by an in-memory byte buffer.
Useful for tests and for round-trips where no actual I/O is required.
◆ MemoryStream() [1/2]
| pulp::runtime::MemoryStream::MemoryStream |
( |
| ) |
|
|
default |
◆ MemoryStream() [2/2]
| pulp::runtime::MemoryStream::MemoryStream |
( |
std::vector< std::uint8_t > | initial | ) |
|
|
explicit |
Pre-fill the stream with existing bytes (copied in).
◆ buffer()
| const std::vector< std::uint8_t > & pulp::runtime::MemoryStream::buffer |
( |
| ) |
const |
|
inline |
Byte content currently in the stream (for inspection in tests).
◆ clear()
| void pulp::runtime::MemoryStream::clear |
( |
| ) |
|
Clear all data and rewind.
◆ close()
| void pulp::runtime::MemoryStream::close |
( |
| ) |
|
|
inlineoverridevirtual |
◆ is_open()
| bool pulp::runtime::MemoryStream::is_open |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ read()
| StreamResult pulp::runtime::MemoryStream::read |
( |
std::uint8_t * | buffer, |
|
|
std::size_t | size ) |
|
overridevirtual |
◆ read_position()
| std::size_t pulp::runtime::MemoryStream::read_position |
( |
| ) |
const |
|
inline |
◆ rewind()
| void pulp::runtime::MemoryStream::rewind |
( |
| ) |
|
|
inline |
Reset the read cursor to the start.
◆ size()
| std::size_t pulp::runtime::MemoryStream::size |
( |
| ) |
const |
|
inline |
◆ write()
| StreamResult pulp::runtime::MemoryStream::write |
( |
const std::uint8_t * | buffer, |
|
|
std::size_t | size ) |
|
overridevirtual |
Write up to size bytes from buffer.
Returns how many bytes were consumed. Partial writes are permitted — callers loop until satisfied or treat the short return as backpressure.
Implements pulp::runtime::Stream.
The documentation for this class was generated from the following file:
- /home/runner/work/pulp/pulp/core/runtime/include/pulp/runtime/stream.hpp