ProtonNet Server 1.0
An Open Solution for all your socket or web api needs.
Loading...
Searching...
No Matches
XmobiTea.ProtonNetCommon.MemoryBuffer Class Referencesealed

Implementation of the IMemoryBuffer interface, providing methods to manage a byte buffer. More...

Inheritance diagram for XmobiTea.ProtonNetCommon.MemoryBuffer:
XmobiTea.ProtonNetCommon.IMemoryBuffer

Public Member Functions

 MemoryBuffer ()
 Initializes a new instance of the MemoryBuffer class.
 
 MemoryBuffer (int capacity)
 Initializes a new instance of the MemoryBuffer class with the specified capacity.
 
 MemoryBuffer (byte[] buffer)
 Initializes a new instance of the MemoryBuffer class with the specified byte array.
 
bool IsEmpty ()
 Checks if the buffer is empty.
 
byte[] ToArray ()
 Converts the entire buffer to a byte array.
 
byte[] ToArray (int position, int length)
 Converts a portion of the buffer to a byte array.
 
void Clear ()
 Clears the buffer.
 
string ExtractString (int position, int length)
 Extracts a string from the buffer.
 
void Remove (int position, int length)
 Removes a portion of the buffer.
 
void Reserve (int capacity)
 Reserves additional capacity for the buffer.
 
void Resize (int length)
 Resizes the buffer to the specified length.
 
void Shift (int positionAmount)
 Shifts the current position in the buffer by the specified amount.
 
int Write (byte value)
 Writes a byte to the buffer.
 
int Write (string text)
 Writes a string to the buffer.
 
int Write (byte[] buffer)
 Writes a byte array to the buffer.
 
int Write (byte[] buffer, int position, int length)
 Writes a portion of a byte array to the buffer.
 
- Public Member Functions inherited from XmobiTea.ProtonNetCommon.IMemoryBuffer

Properties

int Capacity [get]
 Gets the capacity of the current buffer.
 
byte[] Buffer [get]
 Gets the current buffer as a byte array.
 
int Length [get]
 Gets the current length of the buffer.
 
int Position [get]
 Gets the current position in the buffer.
 
byte this[int index] [get]
 Gets the byte at the specified index in the buffer.
 
- Properties inherited from XmobiTea.ProtonNetCommon.IMemoryBuffer

Detailed Description

Implementation of the IMemoryBuffer interface, providing methods to manage a byte buffer.

Constructor & Destructor Documentation

◆ MemoryBuffer() [1/2]

XmobiTea.ProtonNetCommon.MemoryBuffer.MemoryBuffer ( int capacity)

Initializes a new instance of the MemoryBuffer class with the specified capacity.

Parameters
capacityThe initial capacity of the buffer.

◆ MemoryBuffer() [2/2]

XmobiTea.ProtonNetCommon.MemoryBuffer.MemoryBuffer ( byte[] buffer)

Initializes a new instance of the MemoryBuffer class with the specified byte array.

Parameters
bufferThe initial byte array.

Member Function Documentation

◆ Clear()

void XmobiTea.ProtonNetCommon.MemoryBuffer.Clear ( )

Clears the buffer.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ ExtractString()

string XmobiTea.ProtonNetCommon.MemoryBuffer.ExtractString ( int position,
int length )

Extracts a string from the buffer.

Parameters
positionThe starting position in the buffer.
lengthThe length of the string to extract.
Returns
The extracted string.
Exceptions
ArgumentExceptionThrown when the position and length are invalid.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ IsEmpty()

bool XmobiTea.ProtonNetCommon.MemoryBuffer.IsEmpty ( )

Checks if the buffer is empty.

Returns
True if the buffer is empty; otherwise, false.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ Remove()

void XmobiTea.ProtonNetCommon.MemoryBuffer.Remove ( int position,
int length )

Removes a portion of the buffer.

Parameters
positionThe starting position in the buffer.
lengthThe length of the portion to remove.
Exceptions
ArgumentExceptionThrown when the position and length are invalid.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ Reserve()

void XmobiTea.ProtonNetCommon.MemoryBuffer.Reserve ( int capacity)

Reserves additional capacity for the buffer.

Parameters
capacityThe new capacity to reserve.
Exceptions
ArgumentExceptionThrown when the capacity is less than 0.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ Resize()

void XmobiTea.ProtonNetCommon.MemoryBuffer.Resize ( int length)

Resizes the buffer to the specified length.

Parameters
lengthThe new length of the buffer.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ Shift()

void XmobiTea.ProtonNetCommon.MemoryBuffer.Shift ( int positionAmount)

Shifts the current position in the buffer by the specified amount.

Parameters
positionAmountThe amount by which to shift the position.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ ToArray() [1/2]

byte[] XmobiTea.ProtonNetCommon.MemoryBuffer.ToArray ( )

Converts the entire buffer to a byte array.

Returns
A new byte array containing the contents of the buffer.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ ToArray() [2/2]

byte[] XmobiTea.ProtonNetCommon.MemoryBuffer.ToArray ( int position,
int length )

Converts a portion of the buffer to a byte array.

Parameters
positionThe starting position in the buffer.
lengthThe length of the portion to convert.
Returns
A new byte array containing the specified portion of the buffer.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ Write() [1/4]

int XmobiTea.ProtonNetCommon.MemoryBuffer.Write ( byte value)

Writes a byte to the buffer.

Parameters
valueThe byte to write.
Returns
The number of bytes written (1).

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ Write() [2/4]

int XmobiTea.ProtonNetCommon.MemoryBuffer.Write ( byte[] buffer)

Writes a byte array to the buffer.

Parameters
bufferThe byte array to write.
Returns
The number of bytes written.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ Write() [3/4]

int XmobiTea.ProtonNetCommon.MemoryBuffer.Write ( byte[] buffer,
int position,
int length )

Writes a portion of a byte array to the buffer.

Parameters
bufferThe byte array to write from.
positionThe starting position in the byte array.
lengthThe number of bytes to write.
Returns
The number of bytes written.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ Write() [4/4]

int XmobiTea.ProtonNetCommon.MemoryBuffer.Write ( string text)

Writes a string to the buffer.

Parameters
textThe string to write.
Returns
The number of bytes written.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

Property Documentation

◆ Buffer

byte [] XmobiTea.ProtonNetCommon.MemoryBuffer.Buffer
get

Gets the current buffer as a byte array.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ Capacity

int XmobiTea.ProtonNetCommon.MemoryBuffer.Capacity
get

Gets the capacity of the current buffer.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ Length

int XmobiTea.ProtonNetCommon.MemoryBuffer.Length
get

Gets the current length of the buffer.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ Position

int XmobiTea.ProtonNetCommon.MemoryBuffer.Position
get

Gets the current position in the buffer.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.

◆ this[int index]

byte XmobiTea.ProtonNetCommon.MemoryBuffer.this[int index]
get

Gets the byte at the specified index in the buffer.

Implements XmobiTea.ProtonNetCommon.IMemoryBuffer.


The documentation for this class was generated from the following file: