Umbra::InputStream class

Input byte stream abstraction.

InputStream is an abstraction of a byte stream input to Umbra, hiding the storage of computation resources from the implementation. Typical implementations include input from the filesystem, over the network or directly from memory.

Constructors, destructors, conversion operators

~InputStream(void) virtual

Public functions

auto read(void* ptr, uint32_t numBytes) -> uint32_t pure virtual
Read a given number of bytes from the stream.

Function details

uint32_t Umbra::InputStream::read(void* ptr, uint32_t numBytes) pure virtual

Read a given number of bytes from the stream.

ptr A pointer to the destination memory
numBytes Number of bytes to read
Returns The value of numBytes if the operation succeeded; anything else if an error was encountered.

Umbra uses this callback to deserialize computation elements from user storage. The implementation should copy 'numBytes' bytes into the memory pointer to by 'ptr' and return the number of bytes actually read. The caller of this function knows how much data to expect, so a read operation should never be requested that passes the end of stream. If this happens, an error has occurred.

The caller does not buffer the input in any way so if the individual read operation from the underlying storage is slow, the implementation of this function should maintain a read buffer. Note that OS stream read operations such as std::fread may already provide the buffering.

The caller also expects a single read operation to always be fully satisfied; returning anything but 'numBytes' from the operation is always treated as an error.