Class ByteBuffer
Byte sequence.
Implements
Inherited Members
Namespace: OnixS.Fix
Assembly: OnixS.Fix.Engine.dll
Syntax
public sealed class ByteBuffer : IByteBuffer
Constructors
ByteBuffer()
Default constructor that allocates internal storage with some initial capacity (MinCapacity).
Declaration
public ByteBuffer()
ByteBuffer(Byte[])
Constructor that allocates internal storage corresponding to the specified buffer length and copies all bytes from buffer.
Declaration
public ByteBuffer(byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | buffer | byte array |
ByteBuffer(Byte[], Int32)
Constructor that allocates internal storage corresponding to the specified length and copies length of bytes from buffer.
Declaration
public ByteBuffer(byte[] buffer, int length)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | buffer | byte array |
Int32 | length | length of bytes to be copied |
ByteBuffer(Int32)
Constructor which allocates internal storage according to the specified capacity.
Declaration
public ByteBuffer(int capacity)
Parameters
Type | Name | Description |
---|---|---|
Int32 | capacity | size of internal byte array |
ByteBuffer(String)
Constructor that allocates internal storage and copies all bytes encoded from string.
Declaration
public ByteBuffer(string str)
Parameters
Type | Name | Description |
---|---|---|
String | str | string from which byte array is encoded using String.getBytes() |
Fields
MinCapacity
Declaration
public const int MinCapacity = 128
Field Value
Type | Description |
---|---|
Int32 |
Properties
Content
Returns internal storage(byte array).
Declaration
public byte[] Content { get; }
Property Value
Type | Description |
---|---|
Byte[] | internal storage(byte array) |
Length
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
Int32 |
Span
Declaration
public ReadOnlySpan<byte> Span { get; }
Property Value
Type | Description |
---|---|
ReadOnlySpan<Byte> |
Methods
Alloc(Int32)
Allocates a space of given size in byte buffer and returns an allocated span.
Declaration
public Span<byte> Alloc(int size)
Parameters
Type | Name | Description |
---|---|---|
Int32 | size | size of allocated space |
Returns
Type | Description |
---|---|
Span<Byte> | allocated space |
Exceptions
Type | Condition |
---|---|
ArgumentException |
Append(ByteBuffer)
Appends bytes taken from specified byte buffer.
Declaration
public ByteBuffer Append(ByteBuffer byteBuffer)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | byteBuffer | byte buffer |
Returns
Type | Description |
---|---|
ByteBuffer |
Append(Byte)
Appends a byte to byte buffer.
Declaration
public ByteBuffer Append(byte b)
Parameters
Type | Name | Description |
---|---|---|
Byte | b | byte to be appended |
Returns
Type | Description |
---|---|
ByteBuffer |
Append(Byte*, UInt32)
Appends bytes using unsafe pointer.
Declaration
public void Append(byte *bytes, uint length)
Parameters
Type | Name | Description |
---|---|---|
Byte* | bytes | unsafe pointer to bytes in memory |
UInt32 | length | length |
Append(Byte[])
Appends byte array to byte buffer.
Declaration
public ByteBuffer Append(byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | buffer | byte array |
Returns
Type | Description |
---|---|
ByteBuffer |
Append(Byte[], Int32)
Appends byte array to byte buffer with specified length.
Declaration
public ByteBuffer Append(byte[] buffer, int length)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | buffer | byte array |
Int32 | length | length |
Returns
Type | Description |
---|---|
ByteBuffer |
Append(Byte[], Int32, Int32)
Appends byte array to byte buffer from specified offset with specified length.
Declaration
public ByteBuffer Append(byte[] buffer, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | buffer | byte array |
Int32 | offset | offset |
Int32 | length | length |
Returns
Type | Description |
---|---|
ByteBuffer |
Append(Char)
Appends a character to byte buffer.
Declaration
public ByteBuffer Append(char c)
Parameters
Type | Name | Description |
---|---|---|
Char | c | character be appended |
Returns
Type | Description |
---|---|
ByteBuffer |
Append(Int32)
Appends the text representation of the given integer value.
Declaration
public ByteBuffer Append(int value)
Parameters
Type | Name | Description |
---|---|---|
Int32 | value | number |
Returns
Type | Description |
---|---|
ByteBuffer |
Append(ReadOnlySpan<Byte>)
Appends byte span to byte buffer.
Declaration
public ByteBuffer Append(ReadOnlySpan<byte> span)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<Byte> | span | byte span |
Returns
Type | Description |
---|---|
ByteBuffer |
Append(String)
Appends byte array encoded from string to byte buffer.
Declaration
public ByteBuffer Append(string str)
Parameters
Type | Name | Description |
---|---|---|
String | str | string to be appended |
Returns
Type | Description |
---|---|
ByteBuffer |
Append(StringBuilder)
Appends byte array to byte buffer from specified offset with specified length.
Declaration
public ByteBuffer Append(StringBuilder buffer)
Parameters
Type | Name | Description |
---|---|---|
StringBuilder | buffer | byte array |
Returns
Type | Description |
---|---|
ByteBuffer |
Clear()
Clears the byte buffer.
Declaration
public void Clear()
Erase(Int32, Int32)
Erases bytes from specified position and with length form byte buffer.
Declaration
public void Erase(int length, int startPsn = 0)
Parameters
Type | Name | Description |
---|---|---|
Int32 | length | length of bytes to be removed |
Int32 | startPsn | starting position from where bytes will be removed |
FindIndex(Int32, Byte[])
Finds index of bytes sub-sequence in the data of the byte buffer.
Declaration
public int FindIndex(int startPsn, byte[] subBuffer)
Parameters
Type | Name | Description |
---|---|---|
Int32 | startPsn | start position the finding will begin |
Byte[] | subBuffer | bytes sub-sequence to be found |
Returns
Type | Description |
---|---|
Int32 | index of found bytes sub-sequence, or -1 otherwise |
IncLength(Int32)
Increases data size of byte buffer by the specified size.
The buffer is extended if it is not big enough.
Declaration
public void IncLength(int size)
Parameters
Type | Name | Description |
---|---|---|
Int32 | size | number of bytes the data of byte buffer to be increased |
Insert(Byte[], Int32, Int32, Int32)
Inserts the byte array from specified offset with length at the specified position.
Declaration
public void Insert(byte[] buffer, int offset, int length, int startPsn)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | buffer | byte array to insert |
Int32 | offset | offset in bytes array to start from, begins from 0 |
Int32 | length | length to use |
Int32 | startPsn | position to insert at in target (this) buffer |
Reserve(Int32)
Ensures the specified capacity.
Declaration
public void Reserve(int expectedCapacity)
Parameters
Type | Name | Description |
---|---|---|
Int32 | expectedCapacity | capacity to be reserved |
ReserveSpace(Int32)
Reserves additional space in the storage.
Declaration
public void ReserveSpace(int space)
Parameters
Type | Name | Description |
---|---|---|
Int32 | space | number of bytes added to storage |
Resize(Int32)
Resizes data size in byte buffer.
The buffer is extended if it is not big enough.
Declaration
public void Resize(int newSize)
Parameters
Type | Name | Description |
---|---|---|
Int32 | newSize | new size of the data |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
Operators
Implicit(ByteBuffer to ReadOnlySpan<Byte>)
Declaration
public static implicit operator ReadOnlySpan<byte>(ByteBuffer buffer)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer |
Returns
Type | Description |
---|---|
ReadOnlySpan<Byte> |
Explicit Interface Implementations
IByteBuffer.Allocate(UInt32)
Declaration
Span<byte> IByteBuffer.Allocate(uint size)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | size |
Returns
Type | Description |
---|---|
Span<Byte> |
IByteBuffer.Append(ReadOnlySpan<Byte>)
Declaration
void IByteBuffer.Append(ReadOnlySpan<byte> bytes)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<Byte> | bytes |
IByteBuffer.AppendChar(Byte)
Declaration
void IByteBuffer.AppendChar(byte chr)
Parameters
Type | Name | Description |
---|---|---|
Byte | chr |
IByteBuffer.Reset()
Declaration
void IByteBuffer.Reset()
IByteBuffer.ShrinkBy(UInt32)
Declaration
void IByteBuffer.ShrinkBy(uint n)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | n |