Beispiel #1
0
        public bool EndsWith(String255 str)
        {
            if (str.Length > this.Length)
                return(false);

            fixed(char *buffer = this.Buffer)
            return(LibC.WMemCmp(&buffer[this.Length - str.Length], str.Buffer, str.Length) == 0);
        }
Beispiel #2
0
        public void Append(String255 str)
        {
            if ((this.Length + str.Length) > MaximumLength)
                throw new InvalidOperationException(MsgNoMoreSpace);

            fixed(char *buffer = this.Buffer)
            {
                LibC.WMemCpyUnaligned(&buffer[this.Length], str.Buffer, str.Length);
                this.Length        += str.Length;
                buffer[this.Length] = '\0';
            }
        }
Beispiel #3
0
        public String255(char *str, int length)
        {
            if (length > MaximumLength)
                throw new ArgumentException(MsgStrMustBeLessThanMax);

            fixed(char *buffer = this.Buffer)
            {
                LibC.WMemCpy(buffer, str, length);
                buffer[length] = '\0';
            }

            this.Length = (byte)length;
        }
        public int CompareTo(String255 str)
        {
            fixed(char *buffer = this.Buffer)
            {
                int result = LibC.WMemCmp(buffer, str.Buffer, this.Length < str.Length ? this.Length : str.Length);

                if (result == 0)
                {
                    return(this.Length - str.Length);
                }
                return(result);
            }
        }
Beispiel #5
0
        public String255(String255 str, int startIndex, int length)
        {
            if (startIndex >= str.Length)
            {
                throw new ArgumentException("The start index is too large.");
            }
            if (length > str.Length - startIndex)
            {
                throw new ArgumentException("The length is too large.");
            }
            if (length > MaximumLength)
                throw new ArgumentException(MsgStrMustBeLessThanMax);

            fixed(char *buffer = this.Buffer)
            {
                LibC.WMemCpy(buffer, &str.Buffer[startIndex], length);
                buffer[length] = '\0';
            }

            this.Length = (byte)length;
        }