Class 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
Name | Description |
this
(size)
|
|
Fields
Name | Type | Description |
blockSize
|
immutable(ulong) | Size by which the buffer will grow.
|
buffer_
|
ubyte[] | Internal buffer.
|
position
|
ulong | The position of the free area in the buffer.
|
ring
|
ulong | Buffer ring area size. After this position begins buffer overflow area.
|
start
|
ulong | Buffer start position.
|
Properties
Name | Type | Description |
capacity [get]
|
ulong | |
free [get]
|
ulong | |
length [get]
|
ulong | Note that length doesn't return the real length of the data,
but only the array length that will be returned with buffer
next time. Be sure to call buffer and set +=
until length returns 0.
|
opDollar [get]
|
ulong | |
opIndex [get]
|
ubyte[] | After calling it, set += to the length could be
written.
|
opOpAssign [set]
|
WriteBuffer | Sets how many bytes were written. It will shrink the buffer
appropriately. Always set this property after calling
buffer.
|
opSlice [set]
|
ubyte[] | Returns a chunk with data.
|
opIndex [get]
|
ubyte[] | |
opSlice [set]
|
ubyte[] | |
Methods
Name | Description |
opOpAssign
(buffer)
|
Appends data to the buffer.
|