CodecBuffer<T> class abstract

An abstract implementation of a streamable buffer useful for implementing codec algorithms.

CodecBuffer

Type T is the "pointer" to the various memory locations in the buffer, such as the base, read and write ptr locations. T is usually a DartHeapPointer from this library, or the ffi Pointer type. However, this can be user defined.

Writing:

0..writeCount contains the data that has been written to the buffer. The remaining amount is unwrittenCount.

Reading:

0..readCount contains the data that has already been read in the buffer. The remaining amount is unreadCount.

The buffer is constantly being filled and flushed during usage by codecs. It internally keeps track of how many total bytes have been read and written as totalReadCount and totalWriteCount.

Streaming

Codec buffers are read and write streamable. The stream is considered to be atEnd when readCount == writeCount and there are no bytes to read. The stream is considered to be isFull when writeCount == length and there is no more room to place additional bytes.

Implementers

Constructors

CodecBuffer(int length)
Creates a new codec buffer of length.

Properties

basePtr → T
Subclass Responsibility: Return the byte pointer to the memory at the start of the buffer.
no setter
hashCode int
The hash code for this object.
no setterinherited
length int
Length of the internal buffer in bytes.
final
readCount int
Return total number of readCount within the buffer.
getter/setter pair
readPtr → T
Subclass Responsibility: Return the byte pointer to the memory at the readCount offset from the start of the buffer.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
totalReadCount int
Return the total number of readCount since the last hard reset.
no setter
totalWriteCount int
Return the total number of writeCount since the last hard reset.
no setter
unreadCount int
Return total number of remaining bytes available to be read
no setter
unwrittenCount int
Return the number of bytes the buffer still has available for writing.
no setter
writeCount int
Return the number of bytes currently written to the buffer.
getter/setter pair
writePtr → T
Subclass Responsibility: Return the byte pointer to the memory at the writeCount offset from the start of the buffer.
no setter

Methods

atEnd() bool
Return true if all writeCount have been read, false otherwise.
atEndAndIsFull() bool
Return true if all writeCount have been read and there are no remaining unwrittenCount, false otherwise.
baseListView(int length) Uint8List
Subclass Responsibility: Return a Uint8List view on the buffer over the range base..length.
basicNext() int
Subclass Responsibility: Consume and return the next byte.
basicNextPut(int byte) → void
Subclass Responsibility: Put the next byte into the buffer.
basicPeek() int
Subclass Responsibility: Return the next byte without consuming it.
incrementBytesRead(int amount) → void
Update the read position by amount bytes.
incrementBytesWritten(int amount) → void
Update the write position by amount bytes.
isAvailable() bool
Subclass Responsibility: Return true if buffer is available for use, false otherwise
isFull() bool
Return true if there are no unwrittenCount remaining, false otherwise.
next({int onEnd()?}) int
Read and return the next byte. The readCount will be incremented by 1.
nextAll(int amount, {bool upToAmount = false}) List<int>
Consume and answer a List containing up to the next amount of consecutive bytes.
nextPut(int byte, {void onEnd()?}) bool
Put the next byte into the buffer.
nextPutAll(List<int> bytes, [int? start, int? end]) int
Put bytes into the buffer.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
peek({int onEnd()?}) int
Read the next byte without consuming it.
readBytes({bool copy = true, bool reset = false, bool hard = false}) List<int>
Return the read contents of the buffer as a List.
readListView(int length) Uint8List
Subclass Responsibility: Return a Uint8List view on the buffer over the range readCount..length.
release() → void
Subclass Responsibility: Free internal resources used by the buffer.
reset({bool hard = false}) → void
Reset the read/write offsets in the buffer.
resetRead({bool hard = false}) → void
Reset the read offsets in the buffer.
resetWrite({bool hard = false}) → void
Reset the write offsets in the buffer.
toString() String
A string representation of this object.
inherited
writeListView(int length) Uint8List
Subclass Responsibility: Return a Uint8List view on the buffer over the range writeCount..length.
writtenBytes({bool copy = true, bool reset = false, bool hard = false}) List<int>
Return the written contents of the buffer as a List.

Operators

operator ==(Object other) bool
The equality operator.
inherited