C# Class NewTOAPIA.BufferChunk

Inheritance: IDisposable, ICloneable
Afficher le fichier Open project: Wiladams/NewTOAPIA Class Usage Examples

Private Properties

Свойство Type Description
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

Méthodes publiques

Méthode Description
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.

Private Methods

Méthode Description
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

Method Details

BufferChunk() public méthode

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
Résultat System

BufferChunk() public méthode

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'
Résultat System

BufferChunk() public méthode

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
Résultat System

Clear() public méthode

Used to zero out the data area of the BufferChunk.
public Clear ( ) : void
Résultat void

Clone() public méthode

Creates a shallow copy (new Index and Length, duplicate reference to the same Buffer) of a BufferChunk.
public Clone ( ) : object
Résultat object

Compare() public static méthode

public static Compare ( byte obj1, byte obj2 ) : bool
obj1 byte
obj2 byte
Résultat bool

Copy() public static méthode

public static Copy ( byte source ) : byte[]
source byte
Résultat byte[]

CopyFrom() public méthode

public CopyFrom ( IntPtr source, Int32 alength ) : void
source System.IntPtr
alength System.Int32
Résultat void

CopyTo() public méthode

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
Résultat void

CopyTo() public méthode

public CopyTo ( IntPtr destination, Int32 length ) : void
destination IntPtr
length Int32
Résultat void

Dispose() public méthode

Disposes the internal state of the object
public Dispose ( ) : void
Résultat void

GetByte() public méthode

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
Résultat byte

GetDouble() public méthode

public GetDouble ( int index ) : double
index int
Résultat double

GetFloat() public méthode

public GetFloat ( int index ) : float
index int
Résultat float

GetInt16() public méthode

Retrieves 2 bytes inside the BufferChunk
public GetInt16 ( int index ) : Int16
index int Offset into the valid data
Résultat Int16

GetInt32() public méthode

Retrieves 4 bytes inside the BufferChunk
public GetInt32 ( int index ) : int
index int Offset into the valid data
Résultat int

GetInt64() public méthode

Retrieves 8 bytes inside the BufferChunk
public GetInt64 ( int index ) : long
index int Offset into the valid data
Résultat long

GetPaddedUInt16() public méthode

public GetPaddedUInt16 ( int index ) : UInt16
index int
Résultat UInt16

GetPaddedUInt32() public méthode

public GetPaddedUInt32 ( int index ) : UInt32
index int
Résultat UInt32

GetPaddedUInt64() public méthode

public GetPaddedUInt64 ( int index ) : UInt64
index int
Résultat UInt64

GetUInt16() public méthode

Retrieves 2 bytes inside the BufferChunk
public GetUInt16 ( int index ) : UInt16
index int Offset into the valid data
Résultat UInt16

GetUInt32() public méthode

Retrieves 4 bytes inside the BufferChunk
public GetUInt32 ( int index ) : UInt32
index int Offset into the valid data
Résultat UInt32

GetUInt64() public méthode

Retrieves 8 bytes inside the BufferChunk
public GetUInt64 ( int index ) : UInt64
index int Offset into the valid data
Résultat UInt64

GetUTF8String() public méthode

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
Résultat string

NextBufferChunk() public méthode

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
Résultat BufferChunk

NextBufferChunkMax() public méthode

Returns the requested amount of data, or whatever remains if length > this.length
public NextBufferChunkMax ( int length ) : BufferChunk
length int
Résultat BufferChunk

NextByte() public méthode

public NextByte ( ) : byte
Résultat byte

NextDouble() public méthode

public NextDouble ( ) : double
Résultat double

NextFloat() public méthode

public NextFloat ( ) : float
Résultat float

NextInt16() public méthode

public NextInt16 ( ) : Int16
Résultat Int16

NextInt32() public méthode

public NextInt32 ( ) : Int32
Résultat Int32

NextInt64() public méthode

public NextInt64 ( ) : Int64
Résultat Int64

NextUInt16() public méthode

public NextUInt16 ( ) : UInt16
Résultat UInt16

NextUInt32() public méthode

public NextUInt32 ( ) : UInt32
Résultat UInt32

NextUInt64() public méthode

public NextUInt64 ( ) : UInt64
Résultat UInt64

NextUtf8String() public méthode

public NextUtf8String ( int length ) : string
length int
Résultat string

Peek() public méthode

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
Résultat BufferChunk

Reset() public méthode

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
Résultat void

Reset() public méthode

Reset the BufferChunk's Index and Length pointers to supplied values
public Reset ( int index, int length ) : void
index int
length int
Résultat void

SetByte() public méthode

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
Résultat void

SetInt16() public méthode

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
Résultat void

SetInt32() public méthode

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
Résultat void

SetInt64() public méthode

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
Résultat void

SetPaddedUInt16() public méthode

public SetPaddedUInt16 ( int index, UInt16 data ) : void
index int
data UInt16
Résultat void

SetPaddedUInt32() public méthode

public SetPaddedUInt32 ( int index, UInt32 data ) : void
index int
data UInt32
Résultat void

SetPaddedUInt64() public méthode

public SetPaddedUInt64 ( int index, UInt64 data ) : void
index int
data UInt64
Résultat void

SetUInt16() public méthode

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
Résultat void

SetUInt32() public méthode

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
Résultat void

SetUInt64() public méthode

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
Résultat void

SetUTF8String() public méthode

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
Résultat void

operator() public static méthode

Override + and += operator to allow appending of buffers, provided there is room in the left-most BufferChunk
public static operator ( ) : BufferChunk
Résultat BufferChunk

this() public méthode

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
Résultat byte