Skip to content

dlib.core.stream

Timur Gafarov edited this page Apr 26, 2017 · 8 revisions

dlib.core.stream

Binary I/O stream interfaces.

Type aliases

  • StreamPos - an alias to std.stdint.uint64_t.
  • StreamSize - an alias to std.stdint.uint64_t.
  • StreamOffset - an alias to std.stdint.int64_t.

class SeekException: Exception

An exception which is throwed on stream errors.

interface Seekable

Represents a stream container that knows the size of a stream and allows to change byte position within the stream.

  • StreamPos getPosition() - returns current position.
  • bool setPosition(StreamPos pos) - sets current position to pos. Returns true on success, false on failure.
  • StreamSize size() - returns the size of a stream in bytes.
  • final StreamPos position(StreamPos pos) - sets current position and returns it. Throws SeekException on failure.
  • final StreamPos position() - returns current position.
  • final StreamPos seek(StreamOffset amount) - relatively changes position. amount defines an offset from the current position (can be negative). Throws SeekException on failure.

interface Stream: Seekable

A parent interface for all stream types.

  • void close() - closes the stream. Closed stream cannot be read or written any more.
  • bool seekable() - returns true if it is legal to use Seekable functionality on this stream.

interface InputStream: Stream

A stream that allows to read data from it. Reading any data implies position advance by corresponding number of bytes.

  • bool readable() - returns true if there are any data to read. false means end of the stream.
  • size_t readBytes(void* buffer, size_t count) - tries to read count bytes from stream and stores them in memory pointing by buffer. Returns number of bytes actually read.
  • final bool fillArray(T)(T[] array) - tries to fill an array with raw data from stream. Returns true if the array was filled, false otherwise.
  • final bool readLE(T)(T* value) - reads little-endian integer, converts to native-endian and stores in value.
  • final bool readBE(T)(T* value) - reads big-endian integer, converts to native-endian and stores in value.

interface OutputStream: Stream

  • void flush()
  • bool writeable()
  • size_t writeBytes(const void* buffer, size_t count)
  • final bool writeArray(T)(const T[] array)
  • final bool writeStringz(string text)
  • final bool writeLE(T)(const T value)
  • final bool writeBE(T)(const T value)

interface IOStream: InputStream, OutputStream

class ArrayStream: InputStream

  • this()
  • this(ubyte[] data, size_t size)
  • this(ubyte[] data)

Free functions

  • StreamSize copyFromTo(InputStream input, OutputStream output)
Clone this wiki locally