Buffer
A byte buffer object
This page is a WIP. It contains all the information in Figura's documentation but we're working on adding more helpful descriptions.
getLength()
Returns length of this buffer
getLength()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
getMaxCapacity()
Returns max capacity this buffer can have
getMaxCapacity()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
setPosition()
Sets current position of this buffer
setPosition(position)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position | Integer | - | - |
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon
getPosition()
Returns current position of this buffer
getPosition()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
available()
Returns amount of bytes available to read
available()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
clear()
figura.docs.clear
clear()
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon
close()
Closes this buffer, marking it's memory to be freed by garbage collector. After calling this function buffer cant be used anymore
close()
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon
isClosed()
Checks, is this buffer closed or not
isClosed()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
-- example coming soon
read()
Reads one byte from this buffer
read()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
readBase64()
Reads bytes from this buffer to a Base64 string. Length is amount of bytes to read, default length is 1024
- Overload 1
- Overload 2
Example:
-- example coming soon
readByteArray()
Reads bytes from this buffer to a string byte array. Length is amount of bytes to read, default length is 1024
- Overload 1
- Overload 2
Example:
-- example coming soon
readDouble()
Reads double from this buffer
readDouble()
Returns:
Type | Description |
---|---|
Number | - |
Example:
-- example coming soon
readDoubleLE()
Reads little endian double from this buffer
readDoubleLE()
Returns:
Type | Description |
---|---|
Number | - |
Example:
-- example coming soon
readFloat()
Reads float from this buffer
readFloat()
Returns:
Type | Description |
---|---|
Number | - |
Example:
-- example coming soon
readFloatLE()
Reads little endian float from this buffer
readFloatLE()
Returns:
Type | Description |
---|---|
Number | - |
Example:
-- example coming soon
readFromStream()
Reads data from provided input stream and writes it to buffer, returns amount of bytes wrote
readFromStream(stream, amount)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stream | InputStream | - | - |
amount | Integer | - | - |
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
readInt()
Reads integer from this buffer
readInt()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
readIntLE()
Reads little endian integer from this buffer
readIntLE()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
readLong()
Reads long from this buffer
readLong()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
readLongLE()
Reads little endian long from this buffer
readLongLE()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
readShort()
Reads short from this buffer
readShort()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
readShortLE()
Reads little endian short from this buffer
readShortLE()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
readString()
Reads a string from this buffer. Default encoding is UTF8. Length is amount of bytes to read
- Overload 1
- Overload 2
- Overload 3
Example:
-- example coming soon
readUShort()
Reads unsigned short from this buffer
readUShort()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
readUShortLE()
Reads little endian unsigned short from this buffer
readUShortLE()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
write()
Writes one byte to this buffer
write(val)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val | Integer | - | - |
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon
writeBase64()
Writes bytes of Base64 string to this buffer and returns amount of bytes written.
writeBase64(base64)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base64 | String | - | - |
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
writeByteArray()
Writes raw bytes of string to this buffer and returns amount of bytes written.
writeByteArray(array)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array | String | - | - |
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
writeDouble()
Writes double to this buffer
writeDouble(val)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val | Number | - | - |
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon
writeDoubleLE()
Writes little endian double to this buffer
writeDoubleLE(val)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val | Number | - | - |
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon
writeFloat()
Writes float to this buffer
writeFloat(val)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val | Number | - | - |
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon
writeFloatLE()
Writes little endian float to this buffer
writeFloatLE(val)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val | Number | - | - |
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon
writeInt()
Writes integer to this buffer
writeInt(val)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val | Integer | - | - |
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon
writeIntLE()
Writes little endian integer to this buffer
writeIntLE(val)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val | Integer | - | - |
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon
writeLong()
Writes long to this buffer
writeLong(val)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val | Integer | - | - |
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon
writeLongLE()
Writes little endian long to this buffer
writeLongLE(val)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val | Integer | - | - |
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon
writeShort()
Writes short to this buffer
writeShort(val)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val | Integer | - | - |
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon
writeShortLE()
Writes little endian short to this buffer
writeShortLE(val)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val | Integer | - | - |
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon
writeString()
Writes a string to this buffer and returns amount of bytes written. Default encoding is UTF8.
- Overload 1
- Overload 2
Example:
-- example coming soon
writeToStream()
Writes data from this buffer to provided output stream
writeToStream(stream, amount)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stream | OutputStream | - | - |
amount | Integer | - | - |
Returns:
Type | Description |
---|---|
Integer | - |
Example:
-- example coming soon
writeUShort()
Writes unsigned short to this buffer
writeUShort(val)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val | Integer | - | - |
Returns:
Type | Description |
---|---|
nil | - |
Example:
-- example coming soon