WriteBuffer

Circular, self-expanding buffer with overflow support. Can be used with functions returning 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)

Destructor

~this
~this()

Deallocates the internal buffer.

Members

Functions

opOpAssign
WriteBuffer opOpAssign(ubyte[] buffer)

Appends data to the buffer.

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 buffer) next time. Be sure to call $(D_PSYMBOL buffer) and set $(D_KEYWORD +=) until $(D_PSYMBOL length) returns 0.

opDollar
size_t opDollar [@property getter]
opIndex
ubyte[] opIndex [@property getter]

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

opOpAssign
size_t opOpAssign [@property setter]

Sets how many bytes were written. It will shrink the buffer appropriately. Always set this property after calling $(D_PSYMBOL buffer).

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

Returns a chunk with data.

Variables

blockSize
size_t blockSize;

Size by which the buffer will grow.

buffer_
ubyte[] buffer_;

Internal buffer.

position
size_t position;

The position of the free area in the buffer.

ring
size_t ring;

Buffer ring area size. After this position begins buffer overflow area.

start
size_t start;

Buffer start position.

Inherited Members

From Buffer

capacity
size_t capacity [@property getter]
length
size_t length [@property getter]
free
size_t free [@property getter]
opSlice
ubyte[] opSlice(size_t start, size_t end)
opDollar
size_t opDollar [@property getter]
opIndex
ubyte[] opIndex [@property getter]

Meta