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[], int)
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 |
int | length | length of bytes to be copied |
ByteBuffer(int)
Constructor which allocates internal storage according to the specified capacity.
Declaration
public ByteBuffer(int capacity)
Parameters
Type | Name | Description |
---|---|---|
int | 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
MaxCapacity
Declaration
public const int MaxCapacity = 2147483591
Field Value
Type | Description |
---|---|
int |
MinCapacity
Declaration
public const int MinCapacity = 128
Field Value
Type | Description |
---|---|
int |
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 |
---|---|
int |
Span
Declaration
public ReadOnlySpan<byte> Span { get; }
Property Value
Type | Description |
---|---|
ReadOnlySpan<byte> |
Methods
Alloc(int)
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 |
---|---|---|
int | 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*, uint)
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 |
uint | 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[], int)
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 |
int | length | length |
Returns
Type | Description |
---|---|
ByteBuffer |
Append(byte[], int, int)
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 |
int | offset | offset |
int | 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(int)
Appends the text representation of the given integer value.
Declaration
public ByteBuffer Append(int value)
Parameters
Type | Name | Description |
---|---|---|
int | 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(int, int)
Erases bytes from specified position and with length form byte buffer.
Declaration
public void Erase(int length, int startPsn = 0)
Parameters
Type | Name | Description |
---|---|---|
int | length | length of bytes to be removed |
int | startPsn | starting position from where bytes will be removed |
FindIndex(int, 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 |
---|---|---|
int | startPsn | start position the finding will begin |
byte[] | subBuffer | bytes sub-sequence to be found |
Returns
Type | Description |
---|---|
int | index of found bytes sub-sequence, or -1 otherwise |
IncLength(int)
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 |
---|---|---|
int | size | number of bytes the data of byte buffer to be increased |
Insert(byte[], int, int, int)
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 |
int | offset | offset in bytes array to start from, begins from 0 |
int | length | length to use |
int | startPsn | position to insert at in target (this) buffer |
Reserve(int)
Ensures the specified capacity.
Declaration
public void Reserve(int expectedCapacity)
Parameters
Type | Name | Description |
---|---|---|
int | expectedCapacity | capacity to be reserved |
ReserveSpace(int)
Reserves additional space in the storage.
Declaration
public void ReserveSpace(int space)
Parameters
Type | Name | Description |
---|---|---|
int | space | number of bytes added to storage |
Resize(int)
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 |
---|---|---|
int | newSize | new size of the data |
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents the current object. |
Overrides
Operators
implicit operator ReadOnlySpan<byte>(ByteBuffer)
Declaration
public static implicit operator ReadOnlySpan<byte>(ByteBuffer buffer)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer |
Returns
Type | Description |
---|---|
ReadOnlySpan<byte> |