Module jls.lang.Buffer

Represents a byte array to store temporary data.

Data could be get or set using byte or byte array as string.

Class Buffer

buffer:length () Returns the size of the buffer.
buffer:get ([from[, to]]) Returns the string at the specified position.
buffer:set (value[, offset[, from[, to]]]) Sets the string at the specified position.
buffer:getBytes ([from[, to]]) Returns the bytes at the specified position.
buffer:setBytes (at, ...) Sets the bytes at the specified position.
buffer:view ([from[, to]]) Returns a view on a sub part of this buffer.
Buffer.allocate (size[, mode]) Returns a new buffer for the specified mode.


Class Buffer

The Buffer class.
buffer:length ()
Returns the size of the buffer.

Returns:

    The size of the buffer
buffer:get ([from[, to]])
Returns the string at the specified position.

Parameters:

  • from number The start position, default to 1 (optional)
  • to number The end position included, default to this buffer size (optional)

Returns:

    The string at the specified position
buffer:set (value[, offset[, from[, to]]])
Sets the string at the specified position.

Parameters:

  • value The value to set in this buffer, could be a buffer or a string
  • offset number The position in this buffer to set, default to 1 (optional)
  • from number The start position in the value, default to 1 (optional)
  • to number The end position in the value included, default to the length of the value (optional)
buffer:getBytes ([from[, to]])
Returns the bytes at the specified position.

Parameters:

  • from number The start position, default to 1 (optional)
  • to number The end position included, default to from (optional)

Returns:

    The bytes at the specified position
buffer:setBytes (at, ...)
Sets the bytes at the specified position.

Parameters:

  • at number The position in this buffer to set, default to 1
  • ... The bytes
buffer:view ([from[, to]])
Returns a view on a sub part of this buffer.

Parameters:

  • from number The start position, default to 1 (optional)
  • to number The end position included, default to this buffer size (optional)

Returns:

    The buffer view
Buffer.allocate (size[, mode])
Returns a new buffer for the specified mode.
A local buffer resides in the Lua state. A global buffer resides out of the Lua state but in the Lua process. A shared buffer resides out of the Lua process but in the host.

Parameters:

  • size number the size to allocate, could be a non empty string
  • mode string the mode of buffer, defaults to local (optional)

Returns:

    The new allocated buffer
generated by LDoc 1.5.0