ByteCursor

cc.otavia.buffer.ByteCursor
trait ByteCursor

The ByteCursor scans through a sequence of bytes. This is similar to ByteProcessor, but for external iteration rather than internal iteration. The external iteration allows the callers to control the pace of the iteration.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def bytesLeft: Int

Get the current number of bytes left in the iterator.

Get the current number of bytes left in the iterator.

Attributes

Returns

The number of bytes left in the iterator.

def currentOffset: Int

The current position of this iterator into the underlying sequence of bytes. For instance, if we are iterating a buffer, this would be the iterators current offset into the buffer.

The current position of this iterator into the underlying sequence of bytes. For instance, if we are iterating a buffer, this would be the iterators current offset into the buffer.

Attributes

Returns

The current iterator offset into the underlying sequence of bytes.

def getByte: Byte

Return the last byte that was read by readByte. If readByte has not been called on this cursor before, then -1 is returned.

Return the last byte that was read by readByte. If readByte has not been called on this cursor before, then -1 is returned.

Attributes

Returns

The next byte that was read by the most recent successful call to readByte.

def readByte: Boolean

Check if the iterator has at least one byte left, and if so, read that byte and move the cursor forward. The byte will then be available through the getByte.

Check if the iterator has at least one byte left, and if so, read that byte and move the cursor forward. The byte will then be available through the getByte.

Attributes

Returns

true if the cursor read a byte and moved forward, otherwise false.

Concrete methods

def process(processor: ByteProcessor): Int

Process the remaining bytes in this iterator with the given ByteProcessor. This method consumes the iterator.

Process the remaining bytes in this iterator with the given ByteProcessor. This method consumes the iterator.

Value parameters

processor

The processor to use for processing the bytes in the iterator.

Attributes

Returns

The number of bytes processed, if the ByteProcessor.process method returned false, or -1 if the whole iterator was processed.