コード例 #1
0
        public IEnumerable <ANSIString> Split(char separator)
        {
            int index = 0, newIndex = 0;
            var sep = new ANSIChar(separator);

            do
            {
                newIndex = _String.IndexOf(sep, index);
                if (newIndex < 0)
                {
                    var endstr = new ANSIString();
                    endstr._String.AddRange(_String.Skip(index));
                    yield return(endstr);

                    break;
                }

                var first = index;
                index = _String.IndexOf(sep, index);

                var str = new ANSIString();
                str._String.AddRange(_String.Skip(first).Take(index < 0 ? _String.Count - first : index - first));
                yield return(str);
            }while (index >= 0);
        }
コード例 #2
0
        public static ANSIString operator +(string a, ANSIString b)
        {
            var ret = new ANSIString(a);

            ret.Append(b);
            return(ret);
        }
コード例 #3
0
        public ANSIString Substring(int index, int length = -1)
        {
            var ret = new ANSIString();

            ret._String.AddRange(_String.Skip(index).Take(length < 0 ? _String.Count - index : length));

            return(ret);
        }
コード例 #4
0
        public ANSIString Remove(int index, int length = -1)
        {
            var ret = new ANSIString();

            ret._String.AddRange(_String.Take(index));
            if (length >= 0)
            {
                ret._String.AddRange(_String.Skip(index + length));
            }

            return(ret);
        }
コード例 #5
0
        public static ANSIString Join(ANSIString sep, IEnumerable <ANSIString> parts)
        {
            ANSIString ret = new ANSIString();

            foreach (var part in parts)
            {
                ret += part;
                if (!part.Equals(parts.Last()))
                {
                    ret += sep;
                }
            }

            return(ret);
        }
コード例 #6
0
        public bool Equals(ANSIString other)
        {
            if (Count == other.Count)
            {
                for (int i = 0; i < Count; ++i)
                {
                    if (!this[i].Equals(other[i]))
                    {
                        return(false);
                    }
                }

                return(true);
            }

            return(false);
        }
コード例 #7
0
        public ANSIString Replace(ANSIString search, ANSIString replace)
        {
            int        index = 0;
            ANSIString ret   = new ANSIString(this);

            do
            {
                index = PlainString.IndexOf(search.PlainString, index);
                if (index > 0)
                {
                    for (int i = 0; i < search.Count; ++i)
                    {
                        ret._String[index + i] = replace[i];
                    }
                }
            }while (index > 0);

            return(ret);
        }
コード例 #8
0
        public int CompareTo(ANSIString other)
        {
            string toCompare = PlainString;

            return(toCompare.CompareTo(other.PlainString));
        }
コード例 #9
0
 public void Append(ANSIString other)
 {
     _String.AddRange(other._String);
 }
コード例 #10
0
 public ANSIString(ANSIString String)
 {
     _String = String._String.Select(c => new ANSIChar(c)).ToList();
 }