KS.Reactor.ksOutputBuffer Class Reference

This output buffer converts each written element into one or two byte arrays and adds them to a list. More...

Public Member Functions

void WriteBytes (byte[] bytes)
 Writes bytes to the buffer. More...
 
void Write (bool value)
 Writes a bool to the buffer. More...
 
void Write< T > (T value)
 Writes a struct of type T to the buffer. More...
 
void Write (byte value)
 Writes a byte to the buffer. More...
 
void Write (char value)
 Writes a char to the buffer. 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 a 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 (string value)
 Writes a string to the buffer. More...
 
void Write (bool[] value)
 Writes an array of bools to the buffer. More...
 
void Write (byte[] value)
 Writes an array of bytes to the buffer. More...
 
void Write (char[] value)
 Writes an array of chars to the buffer. More...
 
void Write (short[] value)
 Writes an array of shorts to the buffer. More...
 
void Write (ushort[] value)
 Writes an array of ushort to the buffer. More...
 
void Write (int[] value)
 Writes an array of ints to the buffer. More...
 
void Write (uint[] value)
 Writes an array of uints to the buffer. More...
 
void Write (long[] value)
 Writes an array of longs to the buffer. More...
 
void Write (ulong[] value)
 Write an array of ulongs to the buffer. More...
 
void Write (float[] value)
 Writes an array of floats to the buffer. More...
 
void Write (double[] value)
 Writes an array of doubles to the buffer. More...
 
void Write (string[] value)
 Writes an array of strings to the buffer. More...
 
void Write (ksOutputBuffer value)
 Appends the contents of another output buffer. More...
 
void Write (ksIBufferable value)
 Writes the bytes of an object that implemented ksIBufferable. More...
 
void Write (ksMultiType value)
 Writes a ksMultitype to the buffer. More...
 
void Clear ()
 Clears the buffer. More...
 
byte[] GetBytes ()
 Copies and returns the contents of the buffer as a single byte array. More...
 
byte[] Flush ()
 Gets the buffer bytes then clear the buffer. More...
 

Properties

List< byte[]> Subbuffers [get]
 Gets the list of subbuffers(byte[]) that make up the buffer. More...
 
int Length [get]
 Gets the current byte length of the buffer. More...
 

Detailed Description

This output buffer converts each written element into one or two byte arrays and adds them to a list.

When the output is requested, by calls to GetBytes() or Flush(), the list of byte arrays is copied to a single byte array. This approach is significatly faster for large amounts of data when compared to using memory streams or resizing an array for each write operation.

Member Function Documentation

◆ Clear()

void KS.Reactor.ksOutputBuffer.Clear ( )

Clears the buffer.

◆ Flush()

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

Gets the buffer bytes then clear the buffer.

Returns
Byte array.

◆ GetBytes()

byte [] KS.Reactor.ksOutputBuffer.GetBytes ( )

Copies and returns the contents of the buffer as a single byte array.

Returns
Byte array.

◆ Write() [1/27]

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

Writes a bool to the buffer.

Parameters
valueBool to write.

◆ Write() [2/27]

void KS.Reactor.ksOutputBuffer.Write ( bool[]  value)

Writes an array of bools to the buffer.

Values are first converted to a bit array before writing. If the array is null, then a length of -1 is written.

Parameters
valueBool array to write.

◆ Write() [3/27]

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

Writes a byte to the buffer.

Parameters
valueByte to write.

◆ Write() [4/27]

void KS.Reactor.ksOutputBuffer.Write ( byte[]  value)

Writes an array of bytes to the buffer.

Parameters
valueByte array to write.

◆ Write() [5/27]

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

Writes a char to the buffer.

Parameters
valueChar to write.

◆ Write() [6/27]

void KS.Reactor.ksOutputBuffer.Write ( char[]  value)

Writes an array of chars to the buffer.

Parameters
valueChar array to write.

◆ Write() [7/27]

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

Writes a double to the buffer.

Parameters
valueDouble to write.

◆ Write() [8/27]

void KS.Reactor.ksOutputBuffer.Write ( double[]  value)

Writes an array of doubles to the buffer.

Parameters
valueDouble array to write.

◆ Write() [9/27]

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

Writes a float to the buffer.

Parameters
valueFloat to write.

◆ Write() [10/27]

void KS.Reactor.ksOutputBuffer.Write ( float[]  value)

Writes an array of floats to the buffer.

Parameters
valueFloat array to write.

◆ Write() [11/27]

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

Writes a int to the buffer.

Parameters
valueInt to write.

◆ Write() [12/27]

void KS.Reactor.ksOutputBuffer.Write ( int[]  value)

Writes an array of ints to the buffer.

Parameters
valueInt array to write.

◆ Write() [13/27]

void KS.Reactor.ksOutputBuffer.Write ( ksIBufferable  value)

Writes the bytes of an object that implemented ksIBufferable.

If the object is null write a length value of -1.

Parameters
valueValue to write.

◆ Write() [14/27]

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

Writes a ksMultitype to the buffer.

Parameters
valueValue to write.

◆ Write() [15/27]

void KS.Reactor.ksOutputBuffer.Write ( ksOutputBuffer  value)

Appends the contents of another output buffer.

Parameters
valueValue to write.

◆ Write() [16/27]

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

Writes a long to the buffer.

Parameters
valueLong to write.

◆ Write() [17/27]

void KS.Reactor.ksOutputBuffer.Write ( long[]  value)

Writes an array of longs to the buffer.

Parameters
valueLong array to write.

◆ Write() [18/27]

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

Writes a short to the buffer.

Parameters
valueShort to write.

◆ Write() [19/27]

void KS.Reactor.ksOutputBuffer.Write ( short[]  value)

Writes an array of shorts to the buffer.

Parameters
valueShort array to write.

◆ Write() [20/27]

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

Writes a string to the buffer.

Parameters
valueString to write.

◆ Write() [21/27]

void KS.Reactor.ksOutputBuffer.Write ( string[]  value)

Writes an array of strings to the buffer.

Writes the length of the array followed by each string. If the array is null, then a length of -1 is written.

Parameters
valueString array to write.

◆ Write() [22/27]

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

Writes a uint to the buffer.

Parameters
valueUint to write.

◆ Write() [23/27]

void KS.Reactor.ksOutputBuffer.Write ( uint[]  value)

Writes an array of uints to the buffer.

Parameters
valueUint array to write.

◆ Write() [24/27]

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

Writes a ulong to the buffer.

Parameters
valueUlong to write.

◆ Write() [25/27]

void KS.Reactor.ksOutputBuffer.Write ( ulong[]  value)

Write an array of ulongs to the buffer.

Parameters
valueUlong array to write.

◆ Write() [26/27]

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

Writes a ushort to the buffer.

Parameters
valueUshort to write.

◆ Write() [27/27]

void KS.Reactor.ksOutputBuffer.Write ( ushort[]  value)

Writes an array of ushort to the buffer.

Parameters
valueUshort array to write.

◆ Write< T >()

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

Writes a struct of type T to the buffer.

Template Parameters
T
Parameters
valueStruct to write.
Type Constraints
T :struct 

◆ WriteBytes()

void KS.Reactor.ksOutputBuffer.WriteBytes ( byte[]  bytes)

Writes bytes to the buffer.

Parameters
bytesBytes to write.

Property Documentation

◆ Length

int KS.Reactor.ksOutputBuffer.Length
get

Gets the current byte length of the buffer.

◆ Subbuffers

List<byte[]> KS.Reactor.ksOutputBuffer.Subbuffers
get

Gets the list of subbuffers(byte[]) that make up the buffer.