WriteBuffer.opOpAssign

Appends data to the buffer.

  1. WriteBuffer opOpAssign(ubyte[] buffer)
    class WriteBuffer
    opOpAssign
    (
    string op
    )
    (
    ubyte[] buffer
    )
    if (
    op == "~"
    )
  2. size_t opOpAssign [@property setter]

Parameters

buffer ubyte[]

Buffer chunk got with $(D_PSYMBOL buffer).

Examples

auto b = defaultAllocator.make!WriteBuffer(4);
ubyte[3] buf = [48, 23, 255];

b ~= buf;
assert(b.capacity == 4);
assert(b.buffer_[0] == 48 && b.buffer_[1] == 23 && b.buffer_[2] == 255);

b += 2;
b ~= buf;
assert(b.capacity == 4);
assert(b.buffer_[0] == 23 && b.buffer_[1] == 255
    && b.buffer_[2] == 255 && b.buffer_[3] == 48);

b += 2;
b ~= buf;
assert(b.capacity == 8);
assert(b.buffer_[0] == 23 && b.buffer_[1] == 255
    && b.buffer_[2] == 48 && b.buffer_[3] == 23 && b.buffer_[4] == 255);

defaultAllocator.dispose(b);

b = make!WriteBuffer(defaultAllocator, 2);

b ~= buf;
assert(b.start == 0);
assert(b.capacity == 4);
assert(b.ring == 3);
assert(b.position == 3);

defaultAllocator.dispose(b);

Meta