예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
 public static unsafe NativeSA Serialize(NativeSA target, bool source)
 {
     return(Serialize(target, (int)(source ? 1 : 0)));
 }