Buffer.write

Writes an array using the given endianness.

  1. void write(T value)
  2. void write(T value)
  3. void write(T value)
    class Buffer
    pure nothrow @trusted @nogc
    void
    write
    (
    Endian endianness
    T
    )
    (
    in T value
    )
    if (
    isArray!T &&
    )
  4. void write(T value)
  5. void write(B value)
  6. void write(T value, size_t index)

Examples

t {
		
		Buffer buffer = new Buffer(8);
		buffer.write!(Endian.bigEndian)([1, 2, 3]);
		assert(buffer.capacity == 16);
		assert(buffer.data!ubyte == [0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3]);
		
		buffer.reset();
		buffer.write!(Endian.littleEndian)(cast(short[])[-2, 2]);
		assert(buffer.data!ubyte == [254, 255, 2, 0]);

		buffer.reset();
		buffer.write!(Endian.bigEndian, wstring)("test"w);
		assert(buffer.data!ubyte == [0, 't', 0, 'e', 0, 's', 0, 't']);
	

Meta