ReadBuffer.opOpAssign

Appends some data to the buffer.

class ReadBuffer
opOpAssign
(
string op
)
(
size_t length
)
if (
op == "+"
)

Parameters

length size_t

Number of the bytes read.

Return Value

$(D_KEYWORD this).

Examples

auto b = defaultAllocator.make!ReadBuffer;
size_t numberRead;
ubyte[] result;

// Fills the buffer with values 0..10
numberRead = fillBuffer(b[], b.free, 0, 10);
b += numberRead;

result = b[0..$];
assert(result[0] == 0);
assert(result[1] == 1);
assert(result[9] == 9);
b.clear();

// It shouldn't overwrite, but append another 5 bytes to the buffer
numberRead = fillBuffer(b[], b.free, 0, 10);
b += numberRead;

numberRead = fillBuffer(b[], b.free, 20, 25);
b += numberRead;

result = b[0..$];
assert(result[0] == 0);
assert(result[1] == 1);
assert(result[9] == 9);
assert(result[10] == 20);
assert(result[14] == 24);

defaultAllocator.dispose(b);

Meta