-
-
Notifications
You must be signed in to change notification settings - Fork 32
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. Returnstrueon success,falseon failure. -
StreamSize size()- returns the size of a stream in bytes. -
final StreamPos position(StreamPos pos)- attempts to set current position toposand returns it. ThrowsSeekExceptionon failure. -
final StreamPos position()- returns current position. -
final StreamPos seek(StreamOffset amount)- relatively changes position.amountdefines an offset from the current position (can be negative). ThrowsSeekExceptionon failure.
A parent interface for all stream types.
-
void close()- closes the stream. Closed stream cannot be read or written any more. -
bool seekable()- returnstrueif it is legal to useSeekablefunctionality 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()- returnstrueif there are any data to read.falsemeans end of the stream. -
size_t readBytes(void* buffer, size_t count)- attempts to readcountbytes 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. Returnstrueif the array was filled,falseotherwise. -
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()- returnstrueif stream can be written to. -
size_t writeBytes(const void* buffer, size_t count)- attempts to writecountbytes from the memory pointed bybuffer. Returns number of bytes actually written. -
final bool writeArray(T)(const T[] array)- attempts to write an array. Returnstrueif all elements were written,falseotherwise. -
final bool writeStringz(string text)- attempts to write a string as zero-terminated. Returnstrueif entire string was written,falseotherwise. -
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)- whileinputis readable, reads data frominputand writes it tooutput. Returns number of bytes read.