C# Класс NewTOAPIA.BufferChunk

Наследование: IDisposable, ICloneable
Показать файл Открыть проект Примеры использования класса

Private Properties

Свойство Тип Описание
BufferChunk System
ValidateIntPtr void
ValidateNonNegative void
ValidateNotZeroLength void
ValidateObject void
ValidatePointerData void
ValidateSufficientData void
ValidateSufficientSpace void
_GetFloat float
_GetInt16 Int16
_GetInt32 Int32
_GetUInt64 UInt64
_SetFloat void
_SetInt16 void
_SetInt32 void
_SetUInt64 void

Открытые методы

Метод Описание
BufferChunk ( byte buffer ) : System

Constructor, create a BufferChunk using an existing byte[] without performing a memcopy

BufferChunk ( byte buffer, int index, int length ) : System

Constructor, create a BufferChunk from its constituent parts

BufferChunk ( int size ) : System

Constructor, create a new BufferChunk and allocate a new byte[] to hold the data.

Clear ( ) : void

Used to zero out the data area of the BufferChunk.

Clone ( ) : object

Creates a shallow copy (new Index and Length, duplicate reference to the same Buffer) of a BufferChunk.

Compare ( byte obj1, byte obj2 ) : bool
Copy ( byte source ) : byte[]
CopyFrom ( IntPtr source, Int32 alength ) : void
CopyTo ( BufferChunk destination, int index ) : void

Copy the valid data section of 'this' to the destination BufferChunk overwriting dest's previous contents This method does not allow dest's valid data section to grow or shrink (i.e. treat valid data as a fixed buffer)

CopyTo ( IntPtr destination, Int32 length ) : void
Dispose ( ) : void

Disposes the internal state of the object

GetByte ( int index ) : byte

Retrieves 1 byte from inside the BufferChunk This method is included for consistency. It simply forwards to the indexer.

GetDouble ( int index ) : double
GetFloat ( int index ) : float
GetInt16 ( int index ) : Int16

Retrieves 2 bytes inside the BufferChunk

GetInt32 ( int index ) : int

Retrieves 4 bytes inside the BufferChunk

GetInt64 ( int index ) : long

Retrieves 8 bytes inside the BufferChunk

GetPaddedUInt16 ( int index ) : UInt16
GetPaddedUInt32 ( int index ) : UInt32
GetPaddedUInt64 ( int index ) : UInt64
GetUInt16 ( int index ) : UInt16

Retrieves 2 bytes inside the BufferChunk

GetUInt32 ( int index ) : UInt32

Retrieves 4 bytes inside the BufferChunk

GetUInt64 ( int index ) : UInt64

Retrieves 8 bytes inside the BufferChunk

GetUTF8String ( int index, int length ) : string

Retrieves length bytes from inside the BufferChunk and converts from UTF8 string

NextBufferChunk ( int length ) : BufferChunk

Returns a BufferChunk consisting of the next 'length' bytes of the BufferChunk instance. Automatically increments Index and decrements Length. This function is useful for iterative functions that parse through a large BufferChunk returning smaller BufferChunks

NextBufferChunkMax ( int length ) : BufferChunk

Returns the requested amount of data, or whatever remains if length > this.length

NextByte ( ) : byte
NextDouble ( ) : double
NextFloat ( ) : float
NextInt16 ( ) : Int16
NextInt32 ( ) : Int32
NextInt64 ( ) : Int64
NextUInt16 ( ) : UInt16
NextUInt32 ( ) : UInt32
NextUInt64 ( ) : UInt64
NextUtf8String ( int length ) : string
Peek ( int index, int length ) : BufferChunk

Create a return BufferChunk containing a subset of the data from the valid data.

Reset ( ) : void

Reset the BufferChunk's Index and Length pointers to zero so it is ready for reuse as an empty BufferChunk. Note that the actual byte[] buffer is not reset, so the memory is not deallocated/reallocated, allowing for more efficient reuse of memory without abusing the GC

Reset ( int index, int length ) : void

Reset the BufferChunk's Index and Length pointers to supplied values

SetByte ( int index, byte data ) : void

Modifies 1 byte inside the BufferChunk This method is included for consistency. It simply forwards to the indexer.

SetInt16 ( int index, Int16 data ) : void

Modifies 2 bytes inside the BufferChunk

SetInt32 ( int index, Int32 data ) : void

Modifies 4 bytes inside the BufferChunk

SetInt64 ( int index, Int64 data ) : void

Modifies 8 bytes inside the BufferChunk

SetPaddedUInt16 ( int index, UInt16 data ) : void
SetPaddedUInt32 ( int index, UInt32 data ) : void
SetPaddedUInt64 ( int index, UInt64 data ) : void
SetUInt16 ( int index, UInt16 data ) : void

Modifies 2 bytes inside the BufferChunk

SetUInt32 ( int index, UInt32 data ) : void

Modifies 4 bytes inside the BufferChunk

SetUInt64 ( int index, UInt64 data ) : void

Modifies 8 bytes inside the BufferChunk

SetUTF8String ( int index, string data ) : void

Modifies UTF8.GetBytes(data) bytes inside the BufferChunk

operator ( ) : BufferChunk

Override + and += operator to allow appending of buffers, provided there is room in the left-most BufferChunk

this ( int index ) : byte

Indexer used to allow us to treat a BufferChunk like a byte[]. Useful when making in place modifications or reads from a BufferChunk.

Приватные методы

Метод Описание
BufferChunk ( ) : System
ValidateIntPtr ( IntPtr ptr ) : void
ValidateNonNegative ( int val ) : void
ValidateNotZeroLength ( int length ) : void
ValidateObject ( object o ) : void
ValidatePointerData ( int index, int length, int dataLength ) : void
ValidateSufficientData ( int requested, int actual ) : void
ValidateSufficientSpace ( int requested, int actual ) : void
_GetFloat ( int index ) : float
_GetInt16 ( int index ) : Int16
_GetInt32 ( int index ) : Int32
_GetUInt64 ( int index ) : UInt64
_SetFloat ( int index, float data ) : void
_SetInt16 ( int index, Int16 data ) : void
_SetInt32 ( int index, Int32 data ) : void
_SetUInt64 ( int index, UInt64 data ) : void

Описание методов

BufferChunk() публичный Метод

Constructor, create a BufferChunk using an existing byte[] without performing a memcopy
public BufferChunk ( byte buffer ) : System
buffer byte byte[] to be used as the data store for the BufferChunk, /// cannot be null or zero length
Результат System

BufferChunk() публичный Метод

Constructor, create a BufferChunk from its constituent parts
public BufferChunk ( byte buffer, int index, int length ) : System
buffer byte byte[] to be used as the data store for the BufferChunk
index int offset at which the valid data starts
length int amount of 'valid data'
Результат System

BufferChunk() публичный Метод

Constructor, create a new BufferChunk and allocate a new byte[] to hold the data.
public BufferChunk ( int size ) : System
size int int size of the new byte[] to create, must be >= 1
Результат System

Clear() публичный Метод

Used to zero out the data area of the BufferChunk.
public Clear ( ) : void
Результат void

Clone() публичный Метод

Creates a shallow copy (new Index and Length, duplicate reference to the same Buffer) of a BufferChunk.
public Clone ( ) : object
Результат object

Compare() публичный статический Метод

public static Compare ( byte obj1, byte obj2 ) : bool
obj1 byte
obj2 byte
Результат bool

Copy() публичный статический Метод

public static Copy ( byte source ) : byte[]
source byte
Результат byte[]

CopyFrom() публичный Метод

public CopyFrom ( IntPtr source, Int32 alength ) : void
source System.IntPtr
alength System.Int32
Результат void

CopyTo() публичный Метод

Copy the valid data section of 'this' to the destination BufferChunk overwriting dest's previous contents This method does not allow dest's valid data section to grow or shrink (i.e. treat valid data as a fixed buffer)
public CopyTo ( BufferChunk destination, int index ) : void
destination BufferChunk BufferChunk
index int offset in the destination BufferChunk's valid data
Результат void

CopyTo() публичный Метод

public CopyTo ( IntPtr destination, Int32 length ) : void
destination IntPtr
length Int32
Результат void

Dispose() публичный Метод

Disposes the internal state of the object
public Dispose ( ) : void
Результат void

GetByte() публичный Метод

Retrieves 1 byte from inside the BufferChunk This method is included for consistency. It simply forwards to the indexer.
public GetByte ( int index ) : byte
index int Offset into the valid data
Результат byte

GetDouble() публичный Метод

public GetDouble ( int index ) : double
index int
Результат double

GetFloat() публичный Метод

public GetFloat ( int index ) : float
index int
Результат float

GetInt16() публичный Метод

Retrieves 2 bytes inside the BufferChunk
public GetInt16 ( int index ) : Int16
index int Offset into the valid data
Результат Int16

GetInt32() публичный Метод

Retrieves 4 bytes inside the BufferChunk
public GetInt32 ( int index ) : int
index int Offset into the valid data
Результат int

GetInt64() публичный Метод

Retrieves 8 bytes inside the BufferChunk
public GetInt64 ( int index ) : long
index int Offset into the valid data
Результат long

GetPaddedUInt16() публичный Метод

public GetPaddedUInt16 ( int index ) : UInt16
index int
Результат UInt16

GetPaddedUInt32() публичный Метод

public GetPaddedUInt32 ( int index ) : UInt32
index int
Результат UInt32

GetPaddedUInt64() публичный Метод

public GetPaddedUInt64 ( int index ) : UInt64
index int
Результат UInt64

GetUInt16() публичный Метод

Retrieves 2 bytes inside the BufferChunk
public GetUInt16 ( int index ) : UInt16
index int Offset into the valid data
Результат UInt16

GetUInt32() публичный Метод

Retrieves 4 bytes inside the BufferChunk
public GetUInt32 ( int index ) : UInt32
index int Offset into the valid data
Результат UInt32

GetUInt64() публичный Метод

Retrieves 8 bytes inside the BufferChunk
public GetUInt64 ( int index ) : UInt64
index int Offset into the valid data
Результат UInt64

GetUTF8String() публичный Метод

Retrieves length bytes from inside the BufferChunk and converts from UTF8 string
public GetUTF8String ( int index, int length ) : string
index int Offset into the valid data
length int
Результат string

NextBufferChunk() публичный Метод

Returns a BufferChunk consisting of the next 'length' bytes of the BufferChunk instance. Automatically increments Index and decrements Length. This function is useful for iterative functions that parse through a large BufferChunk returning smaller BufferChunks
public NextBufferChunk ( int length ) : BufferChunk
length int int
Результат BufferChunk

NextBufferChunkMax() публичный Метод

Returns the requested amount of data, or whatever remains if length > this.length
public NextBufferChunkMax ( int length ) : BufferChunk
length int
Результат BufferChunk

NextByte() публичный Метод

public NextByte ( ) : byte
Результат byte

NextDouble() публичный Метод

public NextDouble ( ) : double
Результат double

NextFloat() публичный Метод

public NextFloat ( ) : float
Результат float

NextInt16() публичный Метод

public NextInt16 ( ) : Int16
Результат Int16

NextInt32() публичный Метод

public NextInt32 ( ) : Int32
Результат Int32

NextInt64() публичный Метод

public NextInt64 ( ) : Int64
Результат Int64

NextUInt16() публичный Метод

public NextUInt16 ( ) : UInt16
Результат UInt16

NextUInt32() публичный Метод

public NextUInt32 ( ) : UInt32
Результат UInt32

NextUInt64() публичный Метод

public NextUInt64 ( ) : UInt64
Результат UInt64

NextUtf8String() публичный Метод

public NextUtf8String ( int length ) : string
length int
Результат string

Peek() публичный Метод

Create a return BufferChunk containing a subset of the data from the valid data.
public Peek ( int index, int length ) : BufferChunk
index int int index into the valid data area
length int int length of the data to copy
Результат BufferChunk

Reset() публичный Метод

Reset the BufferChunk's Index and Length pointers to zero so it is ready for reuse as an empty BufferChunk. Note that the actual byte[] buffer is not reset, so the memory is not deallocated/reallocated, allowing for more efficient reuse of memory without abusing the GC
public Reset ( ) : void
Результат void

Reset() публичный Метод

Reset the BufferChunk's Index and Length pointers to supplied values
public Reset ( int index, int length ) : void
index int
length int
Результат void

SetByte() публичный Метод

Modifies 1 byte inside the BufferChunk This method is included for consistency. It simply forwards to the indexer.
public SetByte ( int index, byte data ) : void
index int Offset into the valid data
data byte Value to write at index
Результат void

SetInt16() публичный Метод

Modifies 2 bytes inside the BufferChunk
public SetInt16 ( int index, Int16 data ) : void
index int Offset into the valid data
data Int16 Value to write at index
Результат void

SetInt32() публичный Метод

Modifies 4 bytes inside the BufferChunk
public SetInt32 ( int index, Int32 data ) : void
index int Offset into the valid data
data Int32 Value to write at index
Результат void

SetInt64() публичный Метод

Modifies 8 bytes inside the BufferChunk
public SetInt64 ( int index, Int64 data ) : void
index int Offset into the valid data
data Int64 Value to write at index
Результат void

SetPaddedUInt16() публичный Метод

public SetPaddedUInt16 ( int index, UInt16 data ) : void
index int
data UInt16
Результат void

SetPaddedUInt32() публичный Метод

public SetPaddedUInt32 ( int index, UInt32 data ) : void
index int
data UInt32
Результат void

SetPaddedUInt64() публичный Метод

public SetPaddedUInt64 ( int index, UInt64 data ) : void
index int
data UInt64
Результат void

SetUInt16() публичный Метод

Modifies 2 bytes inside the BufferChunk
public SetUInt16 ( int index, UInt16 data ) : void
index int Offset into the valid data
data UInt16 Value to write at index
Результат void

SetUInt32() публичный Метод

Modifies 4 bytes inside the BufferChunk
public SetUInt32 ( int index, UInt32 data ) : void
index int Offset into the valid data
data UInt32 Value to write at index
Результат void

SetUInt64() публичный Метод

Modifies 8 bytes inside the BufferChunk
public SetUInt64 ( int index, UInt64 data ) : void
index int Offset into the valid data
data UInt64 Value to write at index
Результат void

SetUTF8String() публичный Метод

Modifies UTF8.GetBytes(data) bytes inside the BufferChunk
public SetUTF8String ( int index, string data ) : void
index int Offset into the valid data
data string Value to write at index
Результат void

operator() публичный статический Метод

Override + and += operator to allow appending of buffers, provided there is room in the left-most BufferChunk
public static operator ( ) : BufferChunk
Результат BufferChunk

this() публичный Метод

Indexer used to allow us to treat a BufferChunk like a byte[]. Useful when making in place modifications or reads from a BufferChunk.
public this ( int index ) : byte
index int
Результат byte