public static unsafe NativeSA Serialize(NativeSA target, string source) { int stringLength = source.Length; if (target.EnsureAvailable(stringLength * sizeof(char) + sizeof(int))) { target = Serialize(target, stringLength); if (stringLength > 0) { char *targetCharPtr = (char *)(target.ArrayBegin + target.CurPos); fixed(char *strPtr = source) { char *sourceCharPtr = strPtr; for (int i = 0; i < stringLength; ++i) { *targetCharPtr++ = *sourceCharPtr++; } } target.CurPos += stringLength * sizeof(char); } } return(target); }
public static unsafe NativeSA Serialize(NativeSA target, double source) { if (target.EnsureAvailable(sizeof(double))) { double *dest = (double *)(target.ArrayBegin + target.CurPos); * dest = source; target.CurPos += sizeof(double); } return(target); }
public static unsafe NativeSA Serialize(NativeSA target, float source) { if (target.EnsureAvailable(sizeof(float))) { float *dest = (float *)(target.ArrayBegin + target.CurPos); * dest = source; target.CurPos += sizeof(float); } return(target); }
public static unsafe NativeSA Serialize(NativeSA target, ulong source) { if (target.EnsureAvailable(sizeof(ulong))) { ulong *dest = (ulong *)(target.ArrayBegin + target.CurPos); *dest = source; target.CurPos += sizeof(ulong); } return(target); }
public static unsafe NativeSA Serialize(NativeSA target, float[] array) { int arrayLength = array.Length; if (target.EnsureAvailable(arrayLength * sizeof(float) + sizeof(int))) { target = Serialize(target, arrayLength); float *dest = (float *)(target.ArrayBegin + target.CurPos); for (int i = 0; i < arrayLength; i++) { *dest++ = array[i]; } target.CurPos += arrayLength * sizeof(float); } return(target); }