Advance() public method

public Advance ( ) : bool
return bool
コード例 #1
0
        public static string Take(this Subject subject, int count)
        {
            var result = subject.Text.Substring(subject.Index, count);

            subject.Advance(count);
            return(result);
        }
コード例 #2
0
        public static char Take(this Subject subject)
        {
            if (subject.EndOfString)
            {
                return(char.MinValue);
            }
            var result = subject.Char;

            subject.Advance();
            return(result);
        }
コード例 #3
0
        public static int AdvanceWhile(this Subject subject, char c, long max = int.MaxValue)
        {
            var start = subject.Index;
            var index = start;

            max = Math.Min(start + max, subject.Text.Length);
            while (index < max && subject.Text[index] == c)
            {
                index += 1;
            }
            return(index > start?subject.Advance(index - start) : 0);
        }
コード例 #4
0
        public static int AdvanceWhileNot(this Subject subject, Func <char, bool> predicate, long max = int.MaxValue)
        {
            var start = subject.Index;
            var index = start;

            max = Math.Min(start + max, subject.Text.Length);
            while (index < max && !predicate(subject.Text[index]))
            {
                index += 1;
            }
            return(index > start?subject.Advance(index - start) : 0);
        }