Esempio n. 1
0
        private MyStringBuilder(MyStringBuilder from)
        {
            this.m_ChunkLength   = from.m_ChunkLength;
            this.m_ChunkOffset   = from.m_ChunkOffset;
            this.m_ChunkChars    = from.m_ChunkChars;
            this.m_ChunkPrevious = from.m_ChunkPrevious;
            this.m_MaxCapacity   = from.m_MaxCapacity;

            this.m_ChunkCharsWrapper = from.m_ChunkCharsWrapper;
            this.cap = from.cap;
        }
Esempio n. 2
0
        public unsafe CharArrayWrapper ToCharArrayWrapper()
        {
            CharArrayWrapper resultCaw;

            if (this.cap != null)
            {
                this.cap.Get(out resultCaw, this.Length + 2);
                this.m_ChunkChars = this.m_ChunkCharsWrapper.charArray.content;
            }
            else
            {
                resultCaw = new CharArrayWrapper(null, this.Length + 2, this.Length + 2);
            }

            var result = resultCaw.charArray.content;

            result[this.Length]     = '\0';
            result[this.Length + 1] = '\0';

            if (this.Length == 0)
            {
                return(resultCaw);
            }

            MyStringBuilder chunkPrevious = this;

            fixed(char *str2 = result)
            {
                char *charPtr = str2;

                do
                {
                    if (chunkPrevious.m_ChunkLength > 0)
                    {
                        char[] chunkChars  = chunkPrevious.m_ChunkChars;
                        int    chunkOffset = chunkPrevious.m_ChunkOffset;
                        int    chunkLength = chunkPrevious.m_ChunkLength;
                        if ((((ulong)(chunkLength + chunkOffset)) > (ulong)(result.Length - 1)) || (chunkLength > chunkChars.Length))
                            throw new ArgumentOutOfRangeException("chunkLength");
                        fixed(char *charRef = chunkChars)
                        {
                            Wstrcpy(charPtr + chunkOffset, charRef, chunkLength);
                        }
                    }
                    chunkPrevious = chunkPrevious.m_ChunkPrevious;
                }while (chunkPrevious != null);
            }

            return(resultCaw);
        }