View source code
							
							
						
								Display the source code in std/outbuffer.d from which this
								page was generated on github.
							
						
							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
								local clone.
							
						Class std.outbuffer.OutBuffer
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).
						
				class OutBuffer
				;
						
					
				Methods
| Name | Description | 
|---|---|
| align2(val) | Optimize common special case alignSize(2) | 
| align4(val) | Optimize common special case alignSize(4) | 
| alignSize(alignsize, val) | Append bytes until the buffer aligns on a power of 2 boundary. | 
| clear() | Clear the data in the buffer | 
| fill(nbytes, val) | Append nbytes of val to the internal buffer. | 
| fill0(nbytes) | Append nbytes of 0 to the internal buffer. | 
| printf(format) | Append output of C's printf() to internal buffer. | 
| reserve(nbytes) | Preallocate nbytes more to the size of the internal buffer. | 
| spread(index, nbytes) | At offset index into buffer, create nbytes of space by shifting upwards all data past index. | 
| toBytes() | Convert to array of bytes. | 
| toString() | Convert internal buffer to array of chars. | 
| vprintf(format, args) | Append output of C's vprintf() to internal buffer. | 
| write(bytes) | Append data to the internal buffer. | 
| writef(fmt, args) | Formats and writes its arguments in text format to the OutBuffer. | 
| writefln(fmt, args) | Formats and writes its arguments in text format to the OutBuffer, followed by a newline. | 
| factory(classname) | Create instance of class specified by the fully qualified name classname. The class must either have no constructors or have a default constructor. | 
| opCmp(o) | Compare with another Object obj. | 
| opEquals(o) | Test whether thisis equal too.
 The default implementation only compares by identity (using theisoperator).
 Generally, overrides and overloads foropEqualsshould attempt to compare objects by their contents.
 A class will most likely want to add an overload that takes your specific type as the argument
 and does the content comparison. Then you can override this and forward it to your specific
 typed overload with a cast. Remember to check fornullon the typed overload. | 
| toHash() | Compute hash function for Object. | 
| toString() | Convert Object to a human readable string. | 
Aliases
| Name | Description | 
|---|---|
| put | put enables OutBuffer to be used as an OutputRange. | 
Example
import stdAuthors
License
					Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.