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.
		
	dmd.common.outbuffer
An expandable buffer in which you can write text or binary data.
Authors: 
Walter Bright, https://www.digitalmars.com
License: 
Source root/outbuffer.d
Documentation https://dlang.org/phobos/dmd_root_outbuffer.html
- structOutBuffer;
- OutBufferis a write-only output stream of untyped data. It is backed up by a contiguous array or a memory-mapped file.- booldoindent;
- Whether to indent
- boolspaces;
- Whether to indent by 4 spaces or by tabs;
- intlevel;
- Current indent level
- nothrow @safe this(size_tinitialSize);
- Construct given size.
- nothrow @trusted this(const(char)*filename);
- Construct from filename. Will map the file into memory (or create it anew if necessary) and start writing at the beginning of it.Parameters:const(char)* filenamezero-terminated name of file to map into memory 
- pure nothrow @trusted voiddtor();
- Frees resources associated.
- nothrow @system ubyte*buf();
- For porting with ease from dmd.backend.outbuf.Outbuffer
- nothrow @system ubyte**bufptr();
- For porting with ease from dmd.backend.outbuf.Outbuffer
- pure nothrow @nogc @trusted char*extractData();
- Transfer ownership of the allocated data to the caller.Returns:pointer to the allocated data
- pure nothrow voiddestroy();
- Releases all resources associated with this and resets it as an empty memory buffer. The config variables notlinehead, doindent etc. are not changed.
- pure nothrow @trusted voidreserve(size_tnbytes);
- Reservesnbytesbytes of additional memory (or file space) in advance. The resulting capacity is at least the previous length plusnbytes.Parameters:size_t nbytesthe number of additional bytes to reserve 
- pure nothrow @nogc @safe voidsetsize(size_tsize);
- Shrink the size of the data tosize.Parameters:size_t sizenew size of data, must be <= .length 
- nothrow @safe voidwrite16n(intv);
- Writes a 16 bit value, no reserve check.
- nothrow voidwrite16(intv);
- Writes a 16 bit value.
- nothrow @trusted voidwrite32(intv);
- Writes a 32 bit int.
- nothrow @trusted voidwrite64(longv);
- Writes a 64 bit int.
- pure nothrow @system voidwritestring(const(char)*s);
 pure nothrow @safe voidwritestring(scope const(char)[]s);
 pure nothrow @safe voidwritestring(scope strings);
- Buffer will NOT be zero-terminated
- pure nothrow @safe voidwritestringln(const(char)[]s);
- Buffer will NOT be zero-terminated, followed by newline
- pure nothrow @system voidwriteStringz(const(char)*s);
 pure nothrow @safe voidwriteStringz(const(char)[]s);
 pure nothrow @safe voidwriteStringz(strings);
- Write C string AND null byte
- pure nothrow @safe voidwritenl();
- strip trailing tabs or spaces, write newline
- nothrow @safe voidwriteByten(intb);
- Writes an 8 bit byte, no reserve check.
- pure nothrow @safe char[]allocate(size_tnbytes);
- Allocate space, but leave it uninitialized.Parameters:size_t nbytesamount to allocate Returns:slice of the allocated space to be filled in
- pure nothrow @safe voidprint(ulongu);
- Convertuto a string and append it to the buffer.Parameters:ulong uintegral value to append 
- pure nothrow @system size_tbracket(size_ti, const(char)*left, size_tj, const(char)*right);
- Insert left at i, and right at j. Return index just past right.
- pure nothrow @system size_tinsert(size_toffset, const(void)*p, size_tnbytes);
- Returns:offset + nbytes
- pure nothrow @nogc @safe const(char)[]opSlice() const;
- Returns:a non-owning const slice of the buffer contents
- pure nothrow char[]extractSlice(boolnullTerminate= false);
- Extract the data as a slice and take ownership of it.When true is passed as an argument, this function behaves like dmd.utils.toDString(thisbuffer.extractChars()).Parameters:bool nullTerminateWhen true, the data will be null terminated. This is useful to call C functions or store the result in Strings. Defaults to false. 
- pure nothrow @safe voidwriteHexString(scope const(ubyte)[]data, boolupperCase);
- Write an array as a string of hexadecimal digitsParameters:const(ubyte)[] databytes to write bool upperCasewhether to upper case hex digits A-F 
- nothrow @system boolmoveToFile(const char[]filename);
- Destructively saves the contents of this tofilename. 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.Parameters:char[] filenamethe name of the file to receive the contents Returns:true iff the operation succeeded.
 
Copyright © 1999-2025 by the D Language Foundation | Page generated by
Ddoc on Mon Mar 31 10:27:38 2025