View source code
Display the source code in dmd/common/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.

Struct dmd.common.outbuffer.OutBuffer

OutBuffer is a write-only output stream of untyped data. It is backed up by a contiguous array or a memory-mapped file.

struct OutBuffer ;

Constructors

NameDescription
this (initialSize) Construct given size.
this (filename) Construct from filename. Will map the file into memory (or create it anew if necessary) and start writing at the beginning of it.

Fields

NameTypeDescription
doindent boolWhether to indent
level intCurrent indent level
spaces boolWhether to indent by 4 spaces or by tabs;

Methods

NameDescription
allocate (nbytes) Allocate space, but leave it uninitialized.
bracket (i, left, j, right) Insert left at i, and right at j. Return index just past right.
buf () For porting with ease from dmd.backend.outbuf.Outbuffer
bufptr () For porting with ease from dmd.backend.outbuf.Outbuffer
destroy () Releases all resources associated with this and resets it as an empty memory buffer. The config variables notlinehead, doindent etc. are not changed.
dtor () Frees resources associated.
extractData () Transfer ownership of the allocated data to the caller.
extractSlice (nullTerminate) Extract the data as a slice and take ownership of it.
insert (offset, p, nbytes)
moveToFile (filename) Destructively saves the contents of this to filename. As an optimization, if the file already has identical contents with the buffer, no copying is done. This is because on SSD drives reading is often much faster than writing and because there's a high likelihood an identical file is written during the build process.
opSlice ()
print (u) Convert u to a string and append it to the buffer.
reserve (nbytes) Reserves nbytes bytes of additional memory (or file space) in advance. The resulting capacity is at least the previous length plus nbytes.
setsize (size) Shrink the size of the data to size.
write16 (v) Writes a 16 bit value.
write16n (v) Writes a 16 bit value, no reserve check.
write32 (v) Writes a 32 bit int.
write64 (v) Writes a 64 bit int.
writeByten (b) Writes an 8 bit byte, no reserve check.
writeHexString (data, upperCase) Write an array as a string of hexadecimal digits
writenl () strip trailing tabs or spaces, write newline
writestring (s) Buffer will NOT be zero-terminated
writestringln (s) Buffer will NOT be zero-terminated, followed by newline
writeStringz (s) Write C string AND null byte

Authors

Walter Bright, https://www.digitalmars.com

License

Boost License 1.0