StreamPeerBuffer
Inherits: StreamPeer < Shared < Object
A stream peer used to handle binary data streams.
Description
Section titled “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.
A StreamPeerBuffer 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
Section titled “Properties”| Type | Name | Default |
|---|---|---|
[]u8 | data_array | PackedByteArray() |
Methods
Section titled “Methods”| Returns | Method |
|---|---|
| void | clear() |
| StreamPeerBuffer | duplicate() |
| int | get_position() |
| int | get_size() |
| void | resize(size) |
| void | seek(position) |
Property descriptions
Section titled “Property descriptions”data_array
Section titled “data_array”[]u8 data_array = PackedByteArray()
Setter/getter: set_data_array(), get_data_array()
The underlying data buffer. Setting this value resets the cursor.
Method descriptions
Section titled “Method descriptions”void clear()
Clears the data_array and resets the cursor.
duplicate
Section titled “duplicate”StreamPeerBuffer duplicate() const
Returns a new StreamPeerBuffer with the same data_array content.
get_position
Section titled “get_position”int get_position() const
Returns the current cursor position.
get_size
Section titled “get_size”int get_size() const
Returns the size of data_array.
resize
Section titled “resize”void resize(size: int)
Resizes the data_array. This doesn’t update the cursor.
void seek(position: int)
Moves the cursor to the specified position. position must be a valid index of data_array.