ReadBuffer.opOpAssign

Appends some data to the buffer.

struct ReadBuffer(T = ubyte)
ref
opOpAssign
(
string op
)
(
size_t length
)
if (
op == "+"
)

Parameters

length size_t

Number of the bytes read.

Return Value

$(D_KEYWORD this).

Examples

ReadBuffer!ubyte b;
size_t numberRead;
ubyte[] result;

// Fills the buffer with values 0..10
numberRead = fillBuffer(b[], 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[], 0, 10);
b += numberRead;

numberRead = fillBuffer(b[], 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);

Meta