Table of Contents

Class NativeHelper

Namespace
HelixToolkit
Assembly
HelixToolkit.dll
public static class NativeHelper
Inheritance
NativeHelper
Inherited Members

Methods

ClearMemory(nint, byte, uint)

Clears the memory.

public static void ClearMemory(nint dest, byte value, uint sizeInBytesToClear)

Parameters

dest nint

The dest.

value byte

The value.

sizeInBytesToClear uint

The size in bytes to clear.

CopyStruct<T1, T2>(T1, ref T2)

public static bool CopyStruct<T1, T2>(T1 t1, ref T2 t2) where T1 : unmanaged where T2 : unmanaged

Parameters

t1 T1
t2 T2

Returns

bool

Type Parameters

T1
T2

CopyStruct<T1, T2>(ref T1, ref T2)

public static bool CopyStruct<T1, T2>(ref T1 t1, ref T2 t2) where T1 : unmanaged where T2 : unmanaged

Parameters

t1 T1
t2 T2

Returns

bool

Type Parameters

T1
T2

MemoryCopy(nint, nint, uint)

Unsafe memory copy

public static void MemoryCopy(nint dst, nint src, uint sizeInBytes)

Parameters

dst nint
src nint
sizeInBytes uint

ReadAndPosition<T>(nint, ref T)

Reads the specified T data from a memory location.

public static nint ReadAndPosition<T>(nint source, ref T data) where T : unmanaged

Parameters

source nint

Memory location to read from.

data T

The data write to.

Returns

nint

source pointer + sizeof(T).

Type Parameters

T

Type of a data to read.

ReadOut<T>(nint, out T)

Reads the specified T data from a memory location.

public static void ReadOut<T>(nint source, out T data) where T : unmanaged

Parameters

source nint

Memory location to read from.

data T

The data write to.

Type Parameters

T

Type of a data to read.

ReadStream(Stream)

Read stream to a byte[] buffer.

public static byte[] ReadStream(Stream stream)

Parameters

stream Stream

Input stream.

Returns

byte[]

A byte[] buffer.

ReadStream(Stream, ref int)

Read stream to a byte[] buffer.

public static byte[] ReadStream(Stream stream, ref int readLength)

Parameters

stream Stream

Input stream.

readLength int

Length to read.

Returns

byte[]

A byte[] buffer.

Read<T>(nint)

Reads the specified T data from a memory location.

public static T Read<T>(nint source) where T : unmanaged

Parameters

source nint

Memory location to read from.

Returns

T

The data read from the memory location.

Type Parameters

T

Type of a data to read.

Read<T>(nint, ref T)

Reads the specified T data from a memory location.

public static void Read<T>(nint source, ref T data) where T : unmanaged

Parameters

source nint

Memory location to read from.

data T

The data write to.

Type Parameters

T

Type of a data to read.

Read<T>(nint, T[], uint, uint)

Reads the specified array T[] data from a memory location.

public static nint Read<T>(nint source, T[] data, uint offset, uint count) where T : unmanaged

Parameters

source nint

Memory location to read from.

data T[]

The data write to.

offset uint

The offset in the array to write to.

count uint

The number of T element to read from the memory location.

Returns

nint

source pointer + sizeof(T) * count.

Type Parameters

T

Type of a data to read.

SizeOf<T>()

SizeOf an unmanaged struct

public static int SizeOf<T>() where T : unmanaged

Returns

int

Type Parameters

T

SizeOf<T>(ref T)

SizeOf an unmanaged struct

public static int SizeOf<T>(ref T _) where T : unmanaged

Parameters

_ T

Returns

int

Type Parameters

T

SizeOf<T>(T[])

SizeOf array of unmanaged struct by bytes

public static int SizeOf<T>(T[] array) where T : unmanaged

Parameters

array T[]

Returns

int

Type Parameters

T

StructIsSame4BytesAligned<T>(ref T, ref T)

Compare two structs are the same. To use this function, struct must be 4 bytes aligned.

public static bool StructIsSame4BytesAligned<T>(ref T s1, ref T s2) where T : unmanaged

Parameters

s1 T
s2 T

Returns

bool

Type Parameters

T

StructIsSame<T>(ref T, ref T)

Compare two structs are the same.

public static bool StructIsSame<T>(ref T s1, ref T s2) where T : unmanaged

Parameters

s1 T
s2 T

Returns

bool

Type Parameters

T

Swap<T>(ref T, ref T)

Swaps the value between two references.

public static void Swap<T>(ref T left, ref T right)

Parameters

left T

The left value.

right T

The right value.

Type Parameters

T

Type of a data to swap.

ToString(byte*)

public static string ToString(byte* str)

Parameters

str byte*

Returns

string

ToString(char*)

public static string ToString(char* str)

Parameters

str char*

Returns

string

ToStruct<T1, T2>(T1)

public static T2 ToStruct<T1, T2>(this T1 t1) where T1 : unmanaged where T2 : unmanaged

Parameters

t1 T1

Returns

T2

Type Parameters

T1
T2

ToStruct<T1, T2>(ref T1)

public static T2 ToStruct<T1, T2>(ref T1 t1) where T1 : unmanaged where T2 : unmanaged

Parameters

t1 T1

Returns

T2

Type Parameters

T1
T2

Write<T>(nint, int, ref T)

Writes the specified T data to a memory location with offset

public static nint Write<T>(nint destination, int offset, ref T data) where T : unmanaged

Parameters

destination nint
offset int
data T

Returns

nint

Type Parameters

T

Write<T>(nint, T)

Writes the specified T data to a memory location.

public static nint Write<T>(nint destination, T data) where T : unmanaged

Parameters

destination nint

Memory location to write to.

data T

The data to write.

Returns

nint

destination pointer + sizeof(T).

Type Parameters

T

Type of a data to write.

Write<T>(nint, ref T)

Writes the specified T data to a memory location.

public static nint Write<T>(nint destination, ref T data) where T : unmanaged

Parameters

destination nint

Memory location to write to.

data T

The data to write.

Returns

nint

destination pointer + sizeof(T).

Type Parameters

T

Type of a data to write.

Write<T>(nint, T[], uint, uint)

Writes the specified array T[] data to a memory location.

public static nint Write<T>(nint destination, T[] data, uint offset, uint count) where T : unmanaged

Parameters

destination nint

Memory location to write to.

data T[]

The array of T data to write.

offset uint

The offset in the array to read from.

count uint

The number of T element to write to the memory location.

Returns

nint

destination pointer + sizeof(T) * count.

Type Parameters

T

Type of a data to write.