BufferWriter
A BufferWriter is an abstraction wrapper for buffer
objects
that provides a convenient way of writing data to buffers.
The internal buffer is automatically resized to fit the data that is being written.
Functions
WriteInt8
BufferWriter:
WriteInt8
(
int8:
number
) →
(
)
Write a signed 8-bit integer to the buffer.
WriteUInt8
BufferWriter:
WriteUInt8
(
uint8:
number
) →
(
)
Write an unsigned 8-bit integer to the buffer.
WriteInt16
BufferWriter:
WriteInt16
(
int16:
number
) →
(
)
Write a signed 16-bit integer to the buffer.
WriteUInt16
BufferWriter:
WriteUInt16
(
uint16:
number
) →
(
)
Write an unsigned 16-bit integer to the buffer.
WriteInt32
BufferWriter:
WriteInt32
(
int32:
number
) →
(
)
Write a signed 32-bit integer to the buffer.
WriteUInt32
BufferWriter:
WriteUInt32
(
uint32:
number
) →
(
)
Write an unsigned 32-bit integer to the buffer.
WriteFloat32
BufferWriter:
WriteFloat32
(
f32:
number
) →
(
)
Write a 32-bit single-precision float to the buffer.
WriteFloat64
BufferWriter:
WriteFloat64
(
f64:
number
) →
(
)
Write a 64-bit double-precision float to the buffer.
WriteBool
BufferWriter:
WriteBool
(
bool:
boolean
) →
(
)
Write a boolean to the buffer.
WriteString
BufferWriter:
WriteString
(
str:
string
,
length:
number?
) →
(
)
Write a string to the buffer. An optional length
argument can
be provided to limit the number of bytes read from the string.
INFO
An extra 32-bit integer is stored before the string to mark the
length of the string. If the length of the string is always
known, it is more memory-efficient to use WriteStringRaw
.
WriteStringRaw
BufferWriter:
WriteStringRaw
(
str:
string
,
length:
number?
) →
(
)
Write a string to the buffer. An optional length
argument can
be provided to limit the number of bytes read from the string.
INFO
The length of the string must be known to the reader in order to
read this string from the buffer, as the length of the string is
not stored in the buffer. For strings of dynamic/unknown length,
use WriteString
instead.
WriteDataType
BufferWriter:
WriteDataType
(
value:
any
) →
(
)
Write a DataType to the buffer.
writer:WriteDataType(CFrame.new(0, 10, 5))
Shrink
BufferWriter:
Shrink
(
) →
(
)
Shrinks the capacity of the buffer to the current data size.
GetSize
BufferWriter:
GetSize
(
) →
number
Returns the current data size of the buffer. This is not necessarily equal to the capacity of the buffer.
GetCapacity
BufferWriter:
GetCapacity
(
) →
number
Returns the current capacity of the buffer. This is the length of the internal buffer, which is usually not the same as the length of the stored data.
The buffer capacity automatically grows as data is added.
SetCursor
BufferWriter:
SetCursor
(
position:
number
) →
(
)
Sets the position of the cursor.
GetCursor
BufferWriter:
GetCursor
(
) →
number
Gets the position of the cursor.
ResetCursor
BufferWriter:
ResetCursor
(
) →
(
)
Resets the position of the cursor.
GetBuffer
BufferWriter:
GetBuffer
(
) →
buffer
Returns the buffer
object.
ToString
BufferWriter:
ToString
(
) →
string
Returns the string version of the internal buffer.