WriteBuffer

Circular, self-expanding buffer with overflow support. Can be used with functions returning the number of the transferred bytes.

The buffer is optimized for situations where you read all the data from it at once (without writing to it occasionally). It can become ineffective if you permanently keep some data in the buffer and alternate writing and reading, because it may allocate and move elements.

Constructors

this
this(size_t size, Allocator allocator)
this
this()
Undocumented in source.

Destructor

~this
~this()

Deallocates the internal buffer.

Members

Aliases

opDollar
alias opDollar = length

Note that $(D_PSYMBOL length) doesn't return the real length of the data, but only the array length that will be returned with $(D_PSYMBOL opIndex) next time. Be sure to call $(D_PSYMBOL opIndex) and set $(D_KEYWORD +=) until $(D_PSYMBOL length) returns 0.

Functions

opIndex
T[] opIndex()

After calling it, set $(D_KEYWORD +=) to the length could be written.

opOpAssign
WriteBuffer opOpAssign(T[] buffer)

Appends data to the buffer.

opOpAssign
WriteBuffer opOpAssign(size_t length)

Sets how many bytes were written. It will shrink the buffer appropriately. Always call it after $(D_PSYMBOL opIndex).

opSlice
T[] opSlice(size_t start, size_t end)

Returns a chunk with data.

Mixins

__anonymous
mixin DefaultAllocator
Undocumented in source.

Properties

capacity
size_t capacity [@property getter]
free
size_t free [@property getter]
length
size_t length [@property getter]

Note that $(D_PSYMBOL length) doesn't return the real length of the data, but only the array length that will be returned with $(D_PSYMBOL opIndex) next time. Be sure to call $(D_PSYMBOL opIndex) and set $(D_KEYWORD +=) until $(D_PSYMBOL length) returns 0.

Mixed In Members

From mixin DefaultAllocator

allocator_
Allocator allocator_;

Allocator.

this
this(Allocator allocator)
allocator
shared(Allocator) allocator [@property getter]

This property checks if the allocator was set in the constructor and sets it to the default one, if not.

Parameters

T

Buffer type.

Meta