std.outbuffer
Serialize data to ubyte arrays.
Copyright
Copyright The D Language Foundation 2000 - 2015.
class OutBuffer
Types 1
classOutBuffer
OutBuffer provides a way to build up an array of bytes out of raw data. It is useful for things like preparing an array of bytes to write out to a file. OutBuffer's byte order is the format native to the computer. To control the byte order (endianness), use a class derived from OutBuffer.
OutBuffer's internal buffer is allocated with the GC. Pointers stored into the buffer are scanned by the GC, but you have to ensure proper alignment, e.g. by using alignSize((void*).sizeof).
Fields
ubyte[] datasize_t offsetMethods
void write(scope const(ubyte)[] bytes)Append data to the internal buffer.void write(scope const(wchar)[] chars) @trustedvoid write(scope const(dchar)[] chars) @trustedvoid write(ubyte b)void write(byte b)dittovoid write(char c)dittovoid write(dchar c)dittovoid write(ushort w) @trustedvoid write(short s)dittovoid write(wchar c) @trustedvoid write(uint w) @trustedvoid write(int i)dittovoid write(ulong l) @trustedvoid write(long l)dittovoid write(float f) @trustedvoid write(double f) @trustedvoid write(real f) @trustedvoid write(scope const(char)[] s) @trustedvoid fill(size_t nbytes, ubyte val = 0)Append nbytes of val to the internal buffer. Params: nbytes = Number of bytes to fill. val = Value to fill, defaults to 0.void fill0(size_t nbytes)Append nbytes of 0 to the internal buffer. Param: nbytes - number of bytes to fill.void alignSize(size_t alignsize, ubyte val = 0)Append bytes until the buffer aligns on a power of 2 boundary.void clear()Clear the data in the buffervoid align2(ubyte val = 0)Optimize common special case alignSize(2) Params: val = Value to fill, defaults to 0.void align4(ubyte val = 0)Optimize common special case alignSize(4) Params: val = Value to fill, defaults to 0.void vprintf(scope string format, va_list args) @system nothrowAppend output of C's vprintf() to internal buffer.void writef(Char, A...)(scope const(Char)[] fmt, A args)Formats and writes its arguments in text format to the OutBuffer.void writef(alias fmt, A...)(A args) if (isSomeString!(typeof(fmt)))dittovoid writefln(Char, A...)(scope const(Char)[] fmt, A args)Formats and writes its arguments in text format to the OutBuffer, followed by a newline.void writefln(alias fmt, A...)(A args) if (isSomeString!(typeof(fmt)))dittovoid spread(size_t index, size_t nbytes) pure nothrow @safeAt offset index into buffer, create nbytes of space by shifting upwards all data past index.