StreamPeerBuffer

Inherits:StreamPeer<RefCounted<Object

A stream peer used to handle binary data streams.

Description

A data buffer stream peer that uses a byte array as the stream. This object can be used to handle binary data from network sessions. To handle binary data stored in files,FileAccess can be used directly.

AStreamPeerBuffer object keeps an internal cursor which is the offset in bytes to the start of the buffer. Get and put operations are performed at the cursor position and will move the cursor accordingly.

Properties

PackedByteArray

data_array

PackedByteArray()

Methods

void

clear()

StreamPeerBuffer

duplicate()const

int

get_position()const

int

get_size()const

void

resize(size:int)

void

seek(position:int)


Property Descriptions

PackedByteArraydata_array =PackedByteArray()🔗

The underlying data buffer. Setting this value resets the cursor.

Note: The returned array iscopied and any changes to it will not update the original property value. SeePackedByteArray for more details.


Method Descriptions

voidclear()🔗

Clears thedata_array and resets the cursor.


StreamPeerBufferduplicate()const🔗

Returns a newStreamPeerBuffer with the samedata_array content.


intget_position()const🔗

Returns the current cursor position.


intget_size()const🔗

Returns the size ofdata_array.


voidresize(size:int)🔗

Resizes thedata_array. Thisdoesn't update the cursor.


voidseek(position:int)🔗

Moves the cursor to the specified position.position must be a valid index ofdata_array.


User-contributed notes

Please read theUser-contributed notes policy before submitting a comment.