Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
std.outbuffer
Serialize data to ubyte arrays.
License:
Authors:
Source: std/outbuffer.d
- 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).
- Convert to array of bytes.
- Preallocate nbytes more to the size of the internal buffer.This is a speed optimization, a good guess at the maximum size of the resulting buffer will improve performance by eliminating reallocations and copying.
- Append data to the internal buffer.
- Append nbytes of 0 to the internal buffer.
- 0-fill to align on power of 2 boundary.
- Optimize common special case alignSize(2)
- Optimize common special case alignSize(4)
- Convert internal buffer to array of chars.
- Formats and writes its arguments in text format to the OutBuffer.Parameters:
Char[] fmt format string as described in std.format.formattedWrite A args arguments to be formatted See Also:Examples:OutBuffer b = new OutBuffer(); b.writef("a%sb", 16); assert(b.toString() == "a16b");
- Formats and writes its arguments in text format to the OutBuffer, followed by a newline.Parameters:
Char[] fmt format string as described in std.format.formattedWrite A args arguments to be formatted See Also:Examples:OutBuffer b = new OutBuffer(); b.writefln("a%sb", 16); assert(b.toString() == "a16b\n");
- At offset index into buffer, create nbytes of space by shifting upwards all data past index.
Copyright Digital Mars 2000 - 2015.
| Page generated by
Ddoc on (no date time)