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
CopyStruct<T1, T2>(T1, ref T2)
public static bool CopyStruct<T1, T2>(T1 t1, ref T2 t2) where T1 : unmanaged where T2 : unmanaged
Parameters
t1T1t2T2
Returns
Type Parameters
T1T2
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
t1T1t2T2
Returns
Type Parameters
T1T2
MemoryCopy(nint, nint, uint)
Unsafe memory copy
public static void MemoryCopy(nint dst, nint src, uint sizeInBytes)
Parameters
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
sourcenintMemory location to read from.
dataTThe data write to.
Returns
- nint
source pointer + sizeof(T).
Type Parameters
TType 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
sourcenintMemory location to read from.
dataTThe data write to.
Type Parameters
TType of a data to read.
ReadStream(Stream)
Read stream to a byte[] buffer.
public static byte[] ReadStream(Stream stream)
Parameters
streamStreamInput 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
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
sourcenintMemory location to read from.
Returns
- T
The data read from the memory location.
Type Parameters
TType 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
sourcenintMemory location to read from.
dataTThe data write to.
Type Parameters
TType 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
sourcenintMemory location to read from.
dataT[]The data write to.
offsetuintThe offset in the array to write to.
countuintThe number of T element to read from the memory location.
Returns
- nint
source pointer + sizeof(T) * count.
Type Parameters
TType of a data to read.
SizeOf<T>()
SizeOf an unmanaged struct
public static int SizeOf<T>() where T : unmanaged
Returns
Type Parameters
T
SizeOf<T>(ref T)
SizeOf an unmanaged struct
public static int SizeOf<T>(ref T _) where T : unmanaged
Parameters
_T
Returns
Type Parameters
T
SizeOf<T>(T[])
SizeOf array of unmanaged struct by bytes
public static int SizeOf<T>(T[] array) where T : unmanaged
Parameters
arrayT[]
Returns
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
s1Ts2T
Returns
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
s1Ts2T
Returns
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
leftTThe left value.
rightTThe right value.
Type Parameters
TType of a data to swap.
ToString(byte*)
public static string ToString(byte* str)
Parameters
strbyte*
Returns
ToString(char*)
public static string ToString(char* str)
Parameters
strchar*
Returns
ToStruct<T1, T2>(T1)
public static T2 ToStruct<T1, T2>(this T1 t1) where T1 : unmanaged where T2 : unmanaged
Parameters
t1T1
Returns
- T2
Type Parameters
T1T2
ToStruct<T1, T2>(ref T1)
public static T2 ToStruct<T1, T2>(ref T1 t1) where T1 : unmanaged where T2 : unmanaged
Parameters
t1T1
Returns
- T2
Type Parameters
T1T2
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
Returns
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
destinationnintMemory location to write to.
dataTThe data to write.
Returns
- nint
destination pointer + sizeof(T).
Type Parameters
TType 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
destinationnintMemory location to write to.
dataTThe data to write.
Returns
- nint
destination pointer + sizeof(T).
Type Parameters
TType 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
destinationnintMemory location to write to.
dataT[]The array of T data to write.
offsetuintThe offset in the array to read from.
countuintThe number of T element to write to the memory location.
Returns
- nint
destination pointer + sizeof(T) * count.
Type Parameters
TType of a data to write.