KS.Reactor.ksStreamBuffer Class Reference

Manages a buffer for reading and writing stream data to a byte array. More...

Classes

class  Segment
 Represents a segment of a ksStreamBuffer. More...
 

Public Member Functions

 ksStreamBuffer ()
 Constructor More...
 
 ksStreamBuffer (byte[] data)
 Constructor More...
 
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...
 
int Reserve (int size)
 Reserves space to write to later by advancing the write offset by size , growing the buffer if necessary. More...
 
void Write (byte value)
 Writes a byte value at the current buffer write offset. More...
 
void WriteBytes (byte[] value)
 Writes a byte array at the current buffer write offset. More...
 
void Write (ArraySegment< byte > segment)
 Writes a segment of a byte array to the buffer. More...
 
void Write (sbyte value)
 Writes an sbyte value at the current buffer write offset. More...
 
void Write (short value)
 Writes a short to the buffer. More...
 
void Write (ushort value)
 Writes a ushort to the buffer. More...
 
void Write (int value)
 Writes an int to the buffer. More...
 
void Write (uint value)
 Writes a uint to the buffer. More...
 
void Write (long value)
 Writes a long to the buffer. More...
 
void Write (ulong value)
 Writes a ulong to the buffer. More...
 
void Write (float value)
 Writes a float to the buffer. More...
 
void Write (double value)
 Writes a double to the buffer. More...
 
void Write (char value)
 Writes a char to the buffer. More...
 
void Write (bool value)
 Writes a bool to the buffer. More...
 
void Write (string value)
 Writes a string to the buffer. More...
 
void Write< T > (T value)
 Writes a struct to the buffer. More...
 
void Write (ksISerializable serializable)
 Writes a ksISerializable to the buffer. More...
 
void Write (ksMultiType value)
 Writes a ksMultiType to the buffer. More...
 
void Write (byte[] array)
 Writes a byte array to the buffer along with its size. More...
 
void Write (sbyte[] array)
 Writes an sbyte array to the buffer along with its size. More...
 
void Write (short[] array)
 Writes a short array to the buffer along with its size. More...
 
void Write (ushort[] array)
 Writes a ushort array to the buffer along with its size. More...
 
void Write (int[] array)
 Writes an int array to the buffer along with its size. More...
 
void Write (uint[] array)
 Writes a uint array to the buffer along with its size. More...
 
void Write (long[] array)
 Writes a long array to the buffer along with its size. More...
 
void Write (ulong[] array)
 Writes a ulong array to the buffer along with its size. More...
 
void Write (float[] array)
 Writes a float array to the buffer along with its size. More...
 
void Write (double[] array)
 Writes a double array to the buffer along with its size. More...
 
void Write (char[] array)
 Writes a char array to the buffer along with its size. More...
 
void Write (bool[] array)
 Writes a bool array to the buffer along with its size. More...
 
void Write (string[] array)
 Writes a string array to the buffer along with its size. More...
 
void Write< T > (T[] array)
 Writes a struct T array to the buffer along with its size. More...
 
void Write (ksMultiType[] array)
 Writes an array of multitypes to the buffer. More...
 
void WriteSerializableArray< T > (T[] array)
 Writes an array of T that implement ksISerializable to the buffer along with its size. More...
 
void WriteEncodedValue (int value)
 Writes an int to the buffer using 7-bit encoding. More...
 
void WriteEncodedValue (uint value)
 Writes a uint to the buffer using 7-bit encoding. More...
 
void WriteEncodedValue (long value)
 Writes a long to the buffer using 7-bit encoding. More...
 
void WriteEncodedValue (ulong value)
 Writes a ulong to the buffer using 7-bit encoding. More...
 
void WriteInt24 (int value)
 Writes an int using 3 bytes. More...
 
void WriteUInt24 (uint value)
 Writes a uint using 3 bytes. More...
 
void WriteInt48 (long value)
 Writes a long using 6 bytes. More...
 
void WriteUInt48 (ulong value)
 Writes a ulong using 6 bytes. More...
 
void WriteEncodedArray (int[] array)
 Writes an int array to the buffer using 7-bit encoding. More...
 
void WriteEncodedArray (uint[] array)
 Writes a uint array to the buffer using 7-bit encoding. More...
 
void WriteEncodedArray (long[] array)
 Writes a long array to the buffer using 7-bit encoding. More...
 
void WriteEncodedArray (ulong[] array)
 Writes a ulong array to the buffer using 7-bit encoding. More...
 
byte Read ()
 Reads the byte at the current buffer read offset. More...
 
byte ReadByte ()
 Reads the byte at the current buffer read offset. More...
 
sbyte ReadSByte ()
 Reads an sbyte from the buffer. More...
 
byte[] ReadBytes (int count=-1)
 Reads multiple bytes at the current buffer read offset. More...
 
short ReadShort ()
 Reads a short from the buffer. More...
 
ushort ReadUShort ()
 Reads a ushort from the buffer. More...
 
int ReadInt ()
 Reads an int from the buffer. More...
 
uint ReadUInt ()
 Reads a uint from the buffer. More...
 
long ReadLong ()
 Reads a long from the buffer. More...
 
ulong ReadULong ()
 Reads a ulong from the buffer. More...
 
float ReadFloat ()
 Reads a float from the buffer. More...
 
double ReadDouble ()
 Reads a double from the buffer. More...
 
char ReadChar ()
 Reads a char from the buffer. More...
 
bool ReadBool ()
 Reads a bool from the buffer. More...
 
string ReadString ()
 Reads a string from the buffer. More...
 
Read< T > ()
 Reads a struct from the buffer. More...
 
ReadSerializable< T > ()
 Reads a T that implements ksISerializable from the buffer. More...
 
ksMultiType ReadMultiType ()
 Reads a ksMultiType from the buffer. More...
 
byte[] ReadByteArray ()
 Reads a byte array from the buffer. More...
 
sbyte[] ReadSByteArray ()
 Reads an sbyte array from the buffer. More...
 
short[] ReadShortArray ()
 Reads a short array from the buffer. More...
 
ushort[] ReadUShortArray ()
 Reads a ushort array from the buffer. More...
 
int[] ReadIntArray ()
 Reads an int array from the buffer. More...
 
uint[] ReadUIntArray ()
 Reads a uint array from the buffer. More...
 
long[] ReadLongArray ()
 Reads a long array from the buffer. More...
 
ulong[] ReadULongArray ()
 Reads a ulong array from the buffer. More...
 
float[] ReadFloatArray ()
 Reads a float array from the buffer. More...
 
double[] ReadDoubleArray ()
 Reads a double array from the buffer. More...
 
char[] ReadCharArray ()
 Reads a char array from the buffer. More...
 
bool[] ReadBoolArray ()
 Reads a bool array from the buffer. More...
 
string[] ReadStringArray ()
 Reads a string array from the buffer. More...
 
T[] ReadArray< T > ()
 Reads a struct array from the buffer. More...
 
ksMultiType[] ReadMultiTypeArray ()
 Reads a ksMultiType array from the buffer. More...
 
T[] ReadSerializableArray< T > ()
 Reads an array of T that implement ksISerializable from the buffer. More...
 
int ReadEncodedInt ()
 Reads an int from the buffer using 7-bit encoding. More...
 
uint ReadEncodedUInt ()
 Reads a uint from the buffer using 7-bit encoding. More...
 
long ReadEncodedLong ()
 Reads a long from the buffer using 7-bit encoding. More...
 
ulong ReadEncodedULong ()
 Reads a ulong from the buffer using 7-bit encoding. More...
 
int ReadInt24 ()
 Reads an int using 3 bytes. More...
 
uint ReadUInt24 ()
 Reads a uint using 3 bytes. More...
 
long ReadInt48 ()
 Reads a long using 6 bytes. More...
 
ulong ReadUInt48 ()
 Reads a ulong using 6 bytes. More...
 
int[] ReadEncodedIntArray ()
 Reads an int array from the buffer using 7-bit encoding. More...
 
uint[] ReadEncodedUIntArray ()
 Reads a uint array from the buffer using 7-bit encoding. More...
 
long[] ReadEncodedLongArray ()
 Reads a long array from the buffer using 7-bit encoding. More...
 
ulong[] ReadEncodedULongArray ()
 Reads a ulong array from the buffer using 7-bit encoding. More...
 
byte[] ToArray ()
 Copies and returns the contents of the buffer. More...
 
byte[] CopyAndRelease ()
 Copies and returns the contents of the buffer, and releases the buffer into the pool of available buffers. More...
 
byte[] Flush ()
 Copies and returns the contents of the buffer, and clears the buffer. More...
 
bool TryGetSegment (out Segment segment, int offset=0, int count=-1)
 Attempts to get a segment of the buffer. More...
 
Segment GetSegment (int offset=0, int count=-1)
 Gets a segment of the buffer. More...
 
bool TryRelease ()
 Tries to release the buffer into the pool of available buffers. 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...
 

Static Public Attributes

static int INT24_MIN = -(1 << 23)
 Min value that can be written using WriteInt24(ksIOutputStream, int). More...
 
static int INT24_MAX = (1 << 23) - 1
 Max value that can be written using WriteInt24(ksIOutputStream, int). More...
 
static uint UINT24_MAX = (1 << 24) - 1
 Max value that can be written using WriteUInt24(ksIOutputStream, uint). More...
 
static long INT48_MIN = -((long)1 << 47)
 Min value that can be written using WriteInt48(ksIOutputStream, long). More...
 
static long INT48_MAX = ((long)1 << 47) - 1
 Max value that can be written using WriteInt48(ksIOutputStream, long). More...
 
static ulong UINT48_MAX = ((ulong)1 << 48) - 1
 Max value that can be written using WriteUInt48(ksIOutputStream, ulong). 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 WriteOffset [get, set]
 Current position of the write cursor in the buffer. More...
 
int ReadOffset [get, set]
 Current position of the read cursor in the buffer. More...
 
int Offset [get, set]
 

Detailed Description

Manages a buffer for reading and writing stream data to a byte array.

Constructor & Destructor Documentation

◆ ksStreamBuffer() [1/2]

KS.Reactor.ksStreamBuffer.ksStreamBuffer ( )

Constructor

◆ ksStreamBuffer() [2/2]

KS.Reactor.ksStreamBuffer.ksStreamBuffer ( byte[]  data)

Constructor

Parameters
dataBuffer data

Member Function Documentation

◆ Clear()

void KS.Reactor.ksStreamBuffer.Clear ( bool  zero = false)

Clears all data from the buffer.

Parameters
zeroIf this is true, all bytes in the managed array will be set to 0.

◆ CopyAndRelease()

byte [] KS.Reactor.ksStreamBuffer.CopyAndRelease ( )

Copies and returns the contents of the buffer, and releases the buffer into the pool of available buffers.

Returns
Buffer contents

◆ Create()

static ksStreamBuffer KS.Reactor.ksStreamBuffer.Create ( )
static

Fetches a ksStreamBuffer from a pool of available buffers or create a new ksStreamBuffer if the pool is empty.

Returns

◆ Flush()

byte [] KS.Reactor.ksStreamBuffer.Flush ( )

Copies and returns the contents of the buffer, and clears the buffer.

Returns
Buffer contents

◆ GetSegment()

Segment KS.Reactor.ksStreamBuffer.GetSegment ( int  offset = 0,
int  count = -1 
)

Gets a segment of the buffer.

Throws a IndexOutOfRangeException if the requested start and end indexes go off the buffer.

Parameters
segmentSegement of buffer.
offsetSegment start index.
countSegment size (-1 up to the end of the buffer).
Returns
Buffer segment

◆ Read()

byte KS.Reactor.ksStreamBuffer.Read ( )

Reads the byte at the current buffer read offset.

Returns

◆ Read< T >()

Reads a struct from the buffer.

Template Parameters
TStruct type
Returns
Struct value
Type Constraints
T :struct 

◆ ReadArray< T >()

T [] KS.Reactor.ksStreamBuffer.ReadArray< T > ( )

Reads a struct array from the buffer.

Template Parameters
TStruct type
Returns
Struct array
Type Constraints
T :struct 

◆ ReadBool()

bool KS.Reactor.ksStreamBuffer.ReadBool ( )

Reads a bool from the buffer.

Returns
Bool value

◆ ReadBoolArray()

bool [] KS.Reactor.ksStreamBuffer.ReadBoolArray ( )

Reads a bool array from the buffer.

Returns
Bool array

◆ ReadByte()

byte KS.Reactor.ksStreamBuffer.ReadByte ( )

Reads the byte at the current buffer read offset.

Returns

◆ ReadByteArray()

byte [] KS.Reactor.ksStreamBuffer.ReadByteArray ( )

Reads a byte array from the buffer.

Returns
Byte array

◆ ReadBytes()

byte [] KS.Reactor.ksStreamBuffer.ReadBytes ( int  count = -1)

Reads multiple bytes at the current buffer read offset.

Parameters
countNumber of bytes to read (-1 = up to the end of the buffer).
Returns

◆ ReadChar()

char KS.Reactor.ksStreamBuffer.ReadChar ( )

Reads a char from the buffer.

Returns
Char value

◆ ReadCharArray()

char [] KS.Reactor.ksStreamBuffer.ReadCharArray ( )

Reads a char array from the buffer.

Returns
Char array

◆ ReadDouble()

double KS.Reactor.ksStreamBuffer.ReadDouble ( )

Reads a double from the buffer.

Returns
Double value

◆ ReadDoubleArray()

double [] KS.Reactor.ksStreamBuffer.ReadDoubleArray ( )

Reads a double array from the buffer.

Returns
Double array

◆ ReadEncodedInt()

int KS.Reactor.ksStreamBuffer.ReadEncodedInt ( )

Reads an int from the buffer using 7-bit encoding.

7 bits of the value are read at a time, and the 8th bit indicates if there is more data to read.

Returns
Int value

◆ ReadEncodedIntArray()

int [] KS.Reactor.ksStreamBuffer.ReadEncodedIntArray ( )

Reads an int array from the buffer using 7-bit encoding.

7 bits of each value are read at a time, and the 8th bit indicates if there is more data to read.

Returns
Int array

◆ ReadEncodedLong()

long KS.Reactor.ksStreamBuffer.ReadEncodedLong ( )

Reads a long from the buffer using 7-bit encoding.

7 bits of the value are read at a time, and the 8th bit indicates if there is more data to read.

Returns
Long value

◆ ReadEncodedLongArray()

long [] KS.Reactor.ksStreamBuffer.ReadEncodedLongArray ( )

Reads a long array from the buffer using 7-bit encoding.

7 bits of each value are read at a time, and the 8th bit indicates if there is more data to read.

Returns
Long array

◆ ReadEncodedUInt()

uint KS.Reactor.ksStreamBuffer.ReadEncodedUInt ( )

Reads a uint from the buffer using 7-bit encoding.

7 bits of the value are read at a time, and the 8th bit indicates if there is more data to read.

Returns
UInt value

◆ ReadEncodedUIntArray()

uint [] KS.Reactor.ksStreamBuffer.ReadEncodedUIntArray ( )

Reads a uint array from the buffer using 7-bit encoding.

7 bits of each value are read at a time, and the 8th bit indicates if there is more data to read.

Returns
UInt array

◆ ReadEncodedULong()

ulong KS.Reactor.ksStreamBuffer.ReadEncodedULong ( )

Reads a ulong from the buffer using 7-bit encoding.

7 bits of the value are read at a time, and the 8th bit indicates if there is more data to read.

Returns
ULong value

◆ ReadEncodedULongArray()

ulong [] KS.Reactor.ksStreamBuffer.ReadEncodedULongArray ( )

Reads a ulong array from the buffer using 7-bit encoding.

7 bits of each value are read at a time, and the 8th bit indicates if there is more data to read.

Returns
ULong array

◆ ReadFloat()

float KS.Reactor.ksStreamBuffer.ReadFloat ( )

Reads a float from the buffer.

Returns
Float value

◆ ReadFloatArray()

float [] KS.Reactor.ksStreamBuffer.ReadFloatArray ( )

Reads a float array from the buffer.

Returns
Float array

◆ ReadInt()

int KS.Reactor.ksStreamBuffer.ReadInt ( )

Reads an int from the buffer.

Returns
Int value

◆ ReadInt24()

int KS.Reactor.ksStreamBuffer.ReadInt24 ( )

Reads an int using 3 bytes.

Returns
Int value

◆ ReadInt48()

long KS.Reactor.ksStreamBuffer.ReadInt48 ( )

Reads a long using 6 bytes.

Returns
Long value

◆ ReadIntArray()

int [] KS.Reactor.ksStreamBuffer.ReadIntArray ( )

Reads an int array from the buffer.

Returns
Int array

◆ ReadLong()

long KS.Reactor.ksStreamBuffer.ReadLong ( )

Reads a long from the buffer.

Parameters
inputInput to read from.
Returns
Long value

◆ ReadLongArray()

long [] KS.Reactor.ksStreamBuffer.ReadLongArray ( )

Reads a long array from the buffer.

Returns
Long array

◆ ReadMultiType()

ksMultiType KS.Reactor.ksStreamBuffer.ReadMultiType ( )

Reads a ksMultiType from the buffer.

Returns
MultiType value

◆ ReadMultiTypeArray()

ksMultiType [] KS.Reactor.ksStreamBuffer.ReadMultiTypeArray ( )

Reads a ksMultiType array from the buffer.

Returns
MultiType array

◆ ReadSByte()

sbyte KS.Reactor.ksStreamBuffer.ReadSByte ( )

Reads an sbyte from the buffer.

Returns

◆ ReadSByteArray()

sbyte [] KS.Reactor.ksStreamBuffer.ReadSByteArray ( )

Reads an sbyte array from the buffer.

Returns
SByte array

◆ ReadSerializable< T >()

T KS.Reactor.ksStreamBuffer.ReadSerializable< T > ( )

Reads a T that implements ksISerializable from the buffer.

Template Parameters
TType to read.
Returns
Object value
Type Constraints
T :ksISerializable 
T :new() 

◆ ReadSerializableArray< T >()

T [] KS.Reactor.ksStreamBuffer.ReadSerializableArray< T > ( )

Reads an array of T that implement ksISerializable from the buffer.

Template Parameters
TType that implements ksISerializable
Returns
Object array
Type Constraints
T :ksISerializable 
T :new() 

◆ ReadShort()

short KS.Reactor.ksStreamBuffer.ReadShort ( )

Reads a short from the buffer.

Returns
Short value

◆ ReadShortArray()

short [] KS.Reactor.ksStreamBuffer.ReadShortArray ( )

Reads a short array from the buffer.

Returns
Short array

◆ ReadString()

string KS.Reactor.ksStreamBuffer.ReadString ( )

Reads a string from the buffer.

Returns
String value

◆ ReadStringArray()

string [] KS.Reactor.ksStreamBuffer.ReadStringArray ( )

Reads a string array from the buffer.

Returns
String array

◆ ReadUInt()

uint KS.Reactor.ksStreamBuffer.ReadUInt ( )

Reads a uint from the buffer.

Returns
UInt value

◆ ReadUInt24()

uint KS.Reactor.ksStreamBuffer.ReadUInt24 ( )

Reads a uint using 3 bytes.

Returns
UInt value

◆ ReadUInt48()

ulong KS.Reactor.ksStreamBuffer.ReadUInt48 ( )

Reads a ulong using 6 bytes.

Returns
ULong value

◆ ReadUIntArray()

uint [] KS.Reactor.ksStreamBuffer.ReadUIntArray ( )

Reads a uint array from the buffer.

Returns
UInt array

◆ ReadULong()

ulong KS.Reactor.ksStreamBuffer.ReadULong ( )

Reads a ulong from the buffer.

Returns
ULong value

◆ ReadULongArray()

ulong [] KS.Reactor.ksStreamBuffer.ReadULongArray ( )

Reads a ulong array from the buffer.

Returns
ULong array

◆ ReadUShort()

ushort KS.Reactor.ksStreamBuffer.ReadUShort ( )

Reads a ushort from the buffer.

Returns
UShort value

◆ ReadUShortArray()

ushort [] KS.Reactor.ksStreamBuffer.ReadUShortArray ( )

Reads a ushort array from the buffer.

Returns
UShort array

◆ Release()

void KS.Reactor.ksStreamBuffer.Release ( )

Releases the buffer and put it pool of available buffers.

Throws an exception if the buffer has unreleased segments.

◆ Reserve()

int KS.Reactor.ksStreamBuffer.Reserve ( int  size)

Reserves space to write to later by advancing the write offset by size , growing the buffer if necessary.

Parameters
sizeSize to reserve for writing later.
Returns
The offset to the start of the reserved space.

◆ ResizeBuffer()

void KS.Reactor.ksStreamBuffer.ResizeBuffer ( int  size)

Resizes and zeros the used portion of the manage array.

Parameters
sizeNew size.

◆ ToArray()

byte [] KS.Reactor.ksStreamBuffer.ToArray ( )

Copies and returns the contents of the buffer.

Returns
Buffer contents

◆ TryGetSegment()

bool KS.Reactor.ksStreamBuffer.TryGetSegment ( out Segment  segment,
int  offset = 0,
int  count = -1 
)

Attempts to get a segment of the buffer.

Parameters
segmentSegement of buffer.
offsetSegment start index.
countSegment size (-1 up to the end of the buffer).
Returns
True if a segment could be retrieved.

◆ TryRelease()

bool KS.Reactor.ksStreamBuffer.TryRelease ( )

Tries to release the buffer into the pool of available buffers.

The buffer cannot be released if it has any unreleased segments or if it's size is too large or the pool is full.

Returns
True if the buffer was released.

◆ Write() [1/30]

void KS.Reactor.ksStreamBuffer.Write ( ArraySegment< byte >  segment)

Writes a segment of a byte array to the buffer.

Parameters
segmentSegment to write.

◆ Write() [2/30]

void KS.Reactor.ksStreamBuffer.Write ( bool  value)

Writes a bool to the buffer.

Parameters
valueValue to write.

◆ Write() [3/30]

void KS.Reactor.ksStreamBuffer.Write ( bool[]  array)

Writes a bool array to the buffer along with its size.

Parameters
outputOutput to write to.
arrayArray to write. May be null.

◆ Write() [4/30]

void KS.Reactor.ksStreamBuffer.Write ( byte  value)

Writes a byte value at the current buffer write offset.

Parameters
value

◆ Write() [5/30]

void KS.Reactor.ksStreamBuffer.Write ( byte[]  array)

Writes a byte array to the buffer along with its size.

Parameters
arrayArray to write. May be null.

◆ Write() [6/30]

void KS.Reactor.ksStreamBuffer.Write ( char  value)

Writes a char to the buffer.

Parameters
valueValue to write.

◆ Write() [7/30]

void KS.Reactor.ksStreamBuffer.Write ( char[]  array)

Writes a char array to the buffer along with its size.

Parameters
arrayArray to write. May be null.

◆ Write() [8/30]

void KS.Reactor.ksStreamBuffer.Write ( double  value)

Writes a double to the buffer.

Parameters
valueValue to write.

◆ Write() [9/30]

void KS.Reactor.ksStreamBuffer.Write ( double[]  array)

Writes a double array to the buffer along with its size.

Parameters
arrayArray to write. May be null.

◆ Write() [10/30]

void KS.Reactor.ksStreamBuffer.Write ( float  value)

Writes a float to the buffer.

Parameters
valueValue to write.

◆ Write() [11/30]

void KS.Reactor.ksStreamBuffer.Write ( float[]  array)

Writes a float array to the buffer along with its size.

Parameters
arrayArray to write. May be null.

◆ Write() [12/30]

void KS.Reactor.ksStreamBuffer.Write ( int  value)

Writes an int to the buffer.

Parameters
valueValue to write.

◆ Write() [13/30]

void KS.Reactor.ksStreamBuffer.Write ( int[]  array)

Writes an int array to the buffer along with its size.

Parameters
arrayArray to write. May be null.

◆ Write() [14/30]

void KS.Reactor.ksStreamBuffer.Write ( ksISerializable  serializable)

Writes a ksISerializable to the buffer.

Parameters
valueValue to write. May be null.

◆ Write() [15/30]

void KS.Reactor.ksStreamBuffer.Write ( ksMultiType  value)

Writes a ksMultiType to the buffer.

Parameters
valueValue to write.

◆ Write() [16/30]

void KS.Reactor.ksStreamBuffer.Write ( ksMultiType[]  array)

Writes an array of multitypes to the buffer.

Parameters
arrayArray to write. May be null.

◆ Write() [17/30]

void KS.Reactor.ksStreamBuffer.Write ( long  value)

Writes a long to the buffer.

Parameters
valueValue to write.

◆ Write() [18/30]

void KS.Reactor.ksStreamBuffer.Write ( long[]  array)

Writes a long array to the buffer along with its size.

Parameters
arrayArray to write. May be null.

◆ Write() [19/30]

void KS.Reactor.ksStreamBuffer.Write ( sbyte  value)

Writes an sbyte value at the current buffer write offset.

Parameters
value

◆ Write() [20/30]

void KS.Reactor.ksStreamBuffer.Write ( sbyte[]  array)

Writes an sbyte array to the buffer along with its size.

Parameters
arrayArray to write. May be null.

◆ Write() [21/30]

void KS.Reactor.ksStreamBuffer.Write ( short  value)

Writes a short to the buffer.

Parameters
valueValue to write.

◆ Write() [22/30]

void KS.Reactor.ksStreamBuffer.Write ( short[]  array)

Writes a short array to the buffer along with its size.

Parameters
arrayArray to write. May be null.

◆ Write() [23/30]

void KS.Reactor.ksStreamBuffer.Write ( string  value)

Writes a string to the buffer.

Parameters
valueValue to write. May be null.

◆ Write() [24/30]

void KS.Reactor.ksStreamBuffer.Write ( string[]  array)

Writes a string array to the buffer along with its size.

Parameters
arrayArray to write. May be null.

◆ Write() [25/30]

void KS.Reactor.ksStreamBuffer.Write ( uint  value)

Writes a uint to the buffer.

Parameters
valueValue to write.

◆ Write() [26/30]

void KS.Reactor.ksStreamBuffer.Write ( uint[]  array)

Writes a uint array to the buffer along with its size.

Parameters
arrayArray to write. May be null.

◆ Write() [27/30]

void KS.Reactor.ksStreamBuffer.Write ( ulong  value)

Writes a ulong to the buffer.

Parameters
valueValue to write.

◆ Write() [28/30]

void KS.Reactor.ksStreamBuffer.Write ( ulong[]  array)

Writes a ulong array to the buffer along with its size.

Parameters
arrayArray to write. May be null.

◆ Write() [29/30]

void KS.Reactor.ksStreamBuffer.Write ( ushort  value)

Writes a ushort to the buffer.

Parameters
valueValue to write.

◆ Write() [30/30]

void KS.Reactor.ksStreamBuffer.Write ( ushort[]  array)

Writes a ushort array to the buffer along with its size.

Parameters
arrayArray to write. May be null.

◆ Write< T >() [1/2]

void KS.Reactor.ksStreamBuffer.Write< T > ( value)

Writes a struct to the buffer.

Template Parameters
TStruct type
Parameters
valueValue to write.
Type Constraints
T :struct 

◆ Write< T >() [2/2]

void KS.Reactor.ksStreamBuffer.Write< T > ( T[]  array)

Writes a struct T array to the buffer along with its size.

Template Parameters
TStruct type
Parameters
arrayArray to write. May be null.
Type Constraints
T :struct 

◆ WriteBytes()

void KS.Reactor.ksStreamBuffer.WriteBytes ( byte[]  value)

Writes a byte array at the current buffer write offset.

Parameters
value

◆ WriteEncodedArray() [1/4]

void KS.Reactor.ksStreamBuffer.WriteEncodedArray ( int[]  array)

Writes an int array to the buffer using 7-bit encoding.

7 bits of each value are written at a time, and the 8th bit indicates if there is more data to read.

Parameters
arrayArray to encode. May be null.

◆ WriteEncodedArray() [2/4]

void KS.Reactor.ksStreamBuffer.WriteEncodedArray ( long[]  array)

Writes a long array to the buffer using 7-bit encoding.

7 bits of each value are written at a time, and the 8th bit indicates if there is more data to read.

Parameters
arrayArray to encode. May be null.

◆ WriteEncodedArray() [3/4]

void KS.Reactor.ksStreamBuffer.WriteEncodedArray ( uint[]  array)

Writes a uint array to the buffer using 7-bit encoding.

7 bits of each value are written at a time, and the 8th bit indicates if there is more data to read.

Parameters
arrayArray to encode. May be null.

◆ WriteEncodedArray() [4/4]

void KS.Reactor.ksStreamBuffer.WriteEncodedArray ( ulong[]  array)

Writes a ulong array to the buffer using 7-bit encoding.

7 bits of each value are written at a time, and the 8th bit indicates if there is more data to read.

Parameters
arrayArray to encode. May be null.

◆ WriteEncodedValue() [1/4]

void KS.Reactor.ksStreamBuffer.WriteEncodedValue ( int  value)

Writes an int to the buffer using 7-bit encoding.

7 bits of the value are written at a time, and the 8th bit indicates if there is more data to read.

Parameters
valueValue to encode.

◆ WriteEncodedValue() [2/4]

void KS.Reactor.ksStreamBuffer.WriteEncodedValue ( long  value)

Writes a long to the buffer using 7-bit encoding.

7 bits of the value are written at a time, and the 8th bit indicates if there is more data to read.

Parameters
valueValue to encode.

◆ WriteEncodedValue() [3/4]

void KS.Reactor.ksStreamBuffer.WriteEncodedValue ( uint  value)

Writes a uint to the buffer using 7-bit encoding.

7 bits of the value are written at a time, and the 8th bit indicates if there is more data to read.

Parameters
valueValue to encode.

◆ WriteEncodedValue() [4/4]

void KS.Reactor.ksStreamBuffer.WriteEncodedValue ( ulong  value)

Writes a ulong to the buffer using 7-bit encoding.

7 bits of the value are written at a time, and the 8th bit indicates if there is more data to read.

Parameters
valueValue to encode.

◆ WriteInt24()

void KS.Reactor.ksStreamBuffer.WriteInt24 ( int  value)

Writes an int using 3 bytes.

INT24_MIN is the min value that can be written and INT24_MAX is the max.

Parameters
valueValue to write.

◆ WriteInt48()

void KS.Reactor.ksStreamBuffer.WriteInt48 ( long  value)

Writes a long using 6 bytes.

INT48_MIN is the min value that can be written and INT48_MAX is the max.

Parameters
valueValue to write.

◆ WriteSerializableArray< T >()

void KS.Reactor.ksStreamBuffer.WriteSerializableArray< T > ( T[]  array)

Writes an array of T that implement ksISerializable to the buffer along with its size.

Template Parameters
TType that implements ksISerializable
Parameters
arrayArray to write. May be null.
Type Constraints
T :ksISerializable 

◆ WriteUInt24()

void KS.Reactor.ksStreamBuffer.WriteUInt24 ( uint  value)

Writes a uint using 3 bytes.

UINT24_MAX is the max value that can be written.

Parameters
valueValue to write.

◆ WriteUInt48()

void KS.Reactor.ksStreamBuffer.WriteUInt48 ( ulong  value)

Writes a ulong using 6 bytes.

UINT48_MAX is the max value that can be written.

Parameters
valueValue to write.

Member Data Documentation

◆ INT24_MAX

int KS.Reactor.ksStreamBuffer.INT24_MAX = (1 << 23) - 1
static

Max value that can be written using WriteInt24(ksIOutputStream, int).

◆ INT24_MIN

int KS.Reactor.ksStreamBuffer.INT24_MIN = -(1 << 23)
static

Min value that can be written using WriteInt24(ksIOutputStream, int).

◆ INT48_MAX

long KS.Reactor.ksStreamBuffer.INT48_MAX = ((long)1 << 47) - 1
static

Max value that can be written using WriteInt48(ksIOutputStream, long).

◆ INT48_MIN

long KS.Reactor.ksStreamBuffer.INT48_MIN = -((long)1 << 47)
static

Min value that can be written using WriteInt48(ksIOutputStream, long).

◆ UINT24_MAX

uint KS.Reactor.ksStreamBuffer.UINT24_MAX = (1 << 24) - 1
static

Max value that can be written using WriteUInt24(ksIOutputStream, uint).

◆ UINT48_MAX

ulong KS.Reactor.ksStreamBuffer.UINT48_MAX = ((ulong)1 << 48) - 1
static

Max value that can be written using WriteUInt48(ksIOutputStream, ulong).

Property Documentation

◆ Array

byte [] KS.Reactor.ksStreamBuffer.Array
get

Byte array managed by the stream buffer.

Note: active buffers may only be using up to Count bytes of this array.

◆ Count

int KS.Reactor.ksStreamBuffer.Count
get

Amount of data in the managed array used by the buffer.

◆ ReadOffset

int KS.Reactor.ksStreamBuffer.ReadOffset
getset

Current position of the read cursor in the buffer.

All read operations will access the managed array at this position.

◆ WriteOffset

int KS.Reactor.ksStreamBuffer.WriteOffset
getset

Current position of the write cursor in the buffer.

All write operations will access the managed array at this position.