-
-
Notifications
You must be signed in to change notification settings - Fork 33
dlib.core.stream
Timur Gafarov edited this page Apr 26, 2017
·
8 revisions
Binary I/O stream interfaces.
-
StreamPos
- an alias tostd.stdint.uint64_t
. -
StreamSize
- an alias tostd.stdint.uint64_t
. -
StreamOffset
- an alias tostd.stdint.int64_t
.
An exception which is throwed on stream errors.
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)
- attempts to set current position topos
. Returnstrue
on success,false
on failure. -
StreamSize size()
- returns the size of a stream in bytes. -
final StreamPos position(StreamPos pos)
- attempts to set current position topos
and returns it. ThrowsSeekException
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). ThrowsSeekException
on failure.
A parent interface for all stream types.
-
void close()
- closes the stream. Closed stream cannot be read or written any more. -
bool seekable()
- returnstrue
if it is legal to useSeekable
functionality on this stream.
A stream that allows to read data from it. Reading any data implies position advance by corresponding number of bytes.
-
bool readable()
- returnstrue
if there are any data to read.false
means end of the stream. -
size_t readBytes(void* buffer, size_t count)
- attempts to readcount
bytes from stream and stores them in memory pointing bybuffer
. Returns number of bytes actually read. -
final bool fillArray(T)(T[] array)
- attempts to fill an array with raw data from stream. Returnstrue
if the array was filled,false
otherwise. -
final bool readLE(T)(T* value)
- reads little-endian integer, converts to native-endian and stores invalue
. -
final bool readBE(T)(T* value)
- reads big-endian integer, converts to native-endian and stores invalue
.
A stream that allows to write data into it.
-
void flush()
- implementation-specific method. Usually it writes any unwritten data from output buffer. -
bool writeable()
- returnstrue
if stream can be written to. -
size_t writeBytes(const void* buffer, size_t count)
- attempts to writecount
bytes from the memory pointed bybuffer
. Returns number of bytes actually written. -
final bool writeArray(T)(const T[] array)
- attempts to write an array. Returnstrue
if all elements were written,false
otherwise. -
final bool writeStringz(string text)
- attempts to write a string as zero-terminated. Returnstrue
if entire string was written,false
otherwise. -
final bool writeLE(T)(const T value)
- writes an integer in little-endian encoding. -
final bool writeBE(T)(const T value)
- writes an integer in big-endian encoding.
A stream that allows both reading and writing data.
A stream that encapsulates contents of an array.
-
this()
- initializes stream as empty. -
this(ubyte[] data, size_t size)
- initializes stream with an array of bytes and size ofsize
. -
this(ubyte[] data)
- initializes stream with an array of bytes and size ofdata.length
.
-
StreamSize copyFromTo(InputStream input, OutputStream output)
- whileinput
is readable, reads data frominput
and writes it tooutput
. Returns number of bytes read.