BinaryWriter.write

Writes value to buffer.

For simple types: Writes binary encoded value to buffer.

For Static arrays: All array elements are written as-is, without terminator or length indicator.

For Dynamic arrays and strings: First, an array length is written as 4-byte unsigned integer (regardless if 64 bit or not) followed by array elements.

For C strings (const char*): String is written with null terminator.

To write terminated strings use writeString instead or pass string wrapped in NullTerminated struct. To write arrays without length use writeArray instead.

  1. void write(T value)
    struct BinaryWriter
    void
    write
    (
    T
    )
    ()
  2. void write(T values)

Parameters

value
Type: T

Value to write

Examples

BinaryWriter writer;
writer.write("abc");
writer.write!byte(10);
writeln(writer.buffer); // ['a', 'b', 'c', 10]

Meta