Esempio n. 1
0
        static unsafe bool InternalStrcpy(byte *dest, int destPos, byte *src, int srcPos, int count)
        {
            /* Get size of src and dest */
            int srcLength  = *(int *)(src + StringOperations.GetLengthOffset());
            int destLength = *(int *)(dest + StringOperations.GetLengthOffset());

            /* Ensure the source and destination are big enough */
            if (destPos < 0)
            {
                return(false);
            }
            if (srcPos < 0)
            {
                return(false);
            }
            if (count < 0)
            {
                return(false);
            }
            if (destPos + count > destLength)
            {
                return(false);
            }
            if (srcPos + count > srcLength)
            {
                return(false);
            }

            /* Do the copy */
            MemoryOperations.MemCpy((void *)(dest + StringOperations.GetDataOffset() + destPos * 2),
                                    (void *)(src + StringOperations.GetDataOffset() + srcPos * 2), count * 2);

            return(true);
        }
Esempio n. 2
0
        static unsafe void StringCtor(byte *str, sbyte *value)
        {
            int   len = strlen((byte *)value);
            void *dst = str + StringOperations.GetDataOffset();

            mbstowcs((char *)dst, (byte *)value, len);
        }
Esempio n. 3
0
        static unsafe void StringCtor(byte *str, char *value, int startIndex, int length)
        {
            void *src = value + startIndex;
            int   len = length * sizeof(char);
            void *dst = str + StringOperations.GetDataOffset();

            MemoryOperations.MemCpy(dst, src, len);
        }
Esempio n. 4
0
        static unsafe void StringCtor(byte *str, char[] srcArr, int startIndex, int length)
        {
            void *src = (byte *)MemoryOperations.GetInternalArray(srcArr) + sizeof(char) * startIndex;
            int   len = length * sizeof(char);
            void *dst = str + StringOperations.GetDataOffset();

            MemoryOperations.MemCpy(dst, src, len);
        }
Esempio n. 5
0
        static unsafe void StringCtor(byte *str, char[] srcArr)
        {
            void *src = MemoryOperations.GetInternalArray(srcArr);
            int   len = srcArr.Length * sizeof(char);
            void *dst = str + StringOperations.GetDataOffset();

            MemoryOperations.MemCpy(dst, src, len);
        }
Esempio n. 6
0
        static unsafe void StringCtor(byte *str, char c, int count)
        {
            char *dst = (char *)(str + StringOperations.GetDataOffset());

            for (int i = 0; i < count; i++)
            {
                *dst++ = c;
            }
        }
Esempio n. 7
0
        static unsafe int CompareOrdinalHelper(byte *strA, int indexA, int countA, byte *strB, int indexB, int countB)
        {
            char *a = (char *)(strA + StringOperations.GetDataOffset()) + indexA;
            char *b = (char *)(strB + StringOperations.GetDataOffset()) + indexB;

            for (int i = 0; i < countA; i++, a++, b++)
            {
                if (*a < *b)
                {
                    return(-1);
                }
                else if (*a > *b)
                {
                    return(1);
                }
            }

            return(0);
        }