Constructor. Initializes stream as empty
Constructor. Initializes stream with an array of bytes. size delimits maximum read size
Constructor. Initializes stream with an array of bytes
Returns true if there are any data to read. false means end of the stream.
Attempts to read count bytes from stream and stores them in memory pointing by buffer. Returns number of bytes actually read
Attempts to fill an array with raw data from stream. Returns true if the array was filled, false otherwise
Reads little-endian integer, converts to native-endian and stores in value
Reads big-endian integer, converts to native-endian and stores in value
ubyte[] arr = [23,13,42,71,0,1,1,2,3,5,8]; auto stream = new ArrayStream(arr); assert(stream.size() == arr.length); ubyte[4] buf; assert(stream.readBytes(buf.ptr, buf.length) == buf.length); assert(buf == [23,13,42,71]); assert(stream.getPosition() == buf.length); assert(stream.setPosition(6)); assert(stream.getPosition == 6); assert(stream.readBytes(buf.ptr, buf.length) == buf.length); assert(buf == [1,2,3,5]); assert(stream.readBytes(buf.ptr, buf.length) == 1); assert(buf[0] == 8); assert(!stream.readable); stream.setPosition(1); assert(stream.readable); stream.seek(4); assert(stream.readBytes(buf.ptr, buf.length) == buf.length); assert(buf == [1,1,2,3]); assert(stream.setPosition(arr.length)); assert(!stream.setPosition(arr.length+1)); stream.close(); assert(!stream.readable);
An InputStream that encapsulates contents of an array