Manages a buffer for reading and writing stream data toa byte array. More...
Classes | |
class | Segment |
Represents a segment of a ksStreamBuffer. More... | |
Public Member Functions | |
void | Clear (bool zero=false) |
Clears all data from the buffer. More... | |
void | ResizeBuffer (int size) |
Resizes and zeros the used portion of the manage array. More... | |
void | Write (byte value) |
Writes a byte value at the current buffer offset. More... | |
void | Write (byte[] value) |
Writes a byte array at the current buffer offset. More... | |
void | Write< T > (T value) |
Writes a struct at the current buffer offset. More... | |
byte | Read () |
Reads the byte at the current buffer offset. More... | |
byte[] | ReadBytes (int count=-1) |
Reads multiple bytes at the current buffer offset. More... | |
T | Read< T > () |
Reads the struct at the current buffer offset. More... | |
bool | TryGetSegment (out Segment segment, int offset=0, int count=-1) |
Attempts to get a segment of the buffer. More... | |
void | Release () |
Releases the buffer and put it pool of available buffers. More... | |
Static Public Member Functions | |
static ksStreamBuffer | Create () |
Fetches a ksStreamBuffer from a pool of available buffers or create a new ksStreamBuffer if the pool is empty. More... | |
Properties | |
byte[] | Array [get] |
Byte array managed by the stream buffer. More... | |
int | Count [get] |
Amount of data in the managed array used by the buffer. More... | |
int | Offset [get, set] |
Current position of the cursor in the buffer. More... | |
Manages a buffer for reading and writing stream data toa byte array.
void KS.Reactor.ksStreamBuffer.Clear | ( | bool | zero = false | ) |
Clears all data from the buffer.
zero | If this is true, all bytes in the managed array will be set to 0. |
|
static |
Fetches a ksStreamBuffer from a pool of available buffers or create a new ksStreamBuffer if the pool is empty.
byte KS.Reactor.ksStreamBuffer.Read | ( | ) |
Reads the byte at the current buffer offset.
T KS.Reactor.ksStreamBuffer.Read< T > | ( | ) |
Reads the struct at the current buffer offset.
T |
T | : | struct |
byte [] KS.Reactor.ksStreamBuffer.ReadBytes | ( | int | count = -1 | ) |
Reads multiple bytes at the current buffer offset.
count | Number of bytes to read (-1 = up to the end of the buffer). |
void KS.Reactor.ksStreamBuffer.Release | ( | ) |
Releases the buffer and put it pool of available buffers.
void KS.Reactor.ksStreamBuffer.ResizeBuffer | ( | int | size | ) |
Resizes and zeros the used portion of the manage array.
size | New size. |
bool KS.Reactor.ksStreamBuffer.TryGetSegment | ( | out Segment | segment, |
int | offset = 0 , |
||
int | count = -1 |
||
) |
void KS.Reactor.ksStreamBuffer.Write | ( | byte | value | ) |
Writes a byte value at the current buffer offset.
value |
void KS.Reactor.ksStreamBuffer.Write | ( | byte[] | value | ) |
Writes a byte array at the current buffer offset.
value |
void KS.Reactor.ksStreamBuffer.Write< T > | ( | T | value | ) |
Writes a struct at the current buffer offset.
T |
value |
T | : | struct |
|
get |
Byte array managed by the stream buffer.
Note: active buffers may only be using up to Count bytes of this array.
|
get |
Amount of data in the managed array used by the buffer.
|
getset |
Current position of the cursor in the buffer.
All read/write operations will access the managed array at this position.