OutBuffer buf = new OutBuffer(); buf.write(cast(ubyte) 1); buf.align2(); assert(buf.toBytes() == "\x01\x00"); buf.write(cast(ubyte) 2); buf.align4(); assert(buf.toBytes() == "\x01\x00\x02\x00"); buf.write(cast(ubyte) 3); buf.alignSize(8); assert(buf.toBytes() == "\x01\x00\x02\x00\x03\x00\x00\x00");
ditto
OutBuffer buf = new OutBuffer(); buf.write(cast(ubyte) 1); buf.align2(0x55); assert(buf.toBytes() == "\x01\x55"); buf.write(cast(ubyte) 2); buf.align4(0x55); assert(buf.toBytes() == "\x01\x55\x02\x55"); buf.write(cast(ubyte) 3); buf.alignSize(8, 0x55); assert(buf.toBytes() == "\x01\x55\x02\x55\x03\x55\x55\x55");
Append bytes until the buffer aligns on a power of 2 boundary.
By default fills with 0 bytes.