MatchWhiteSpaces() public method

Matches a sequence of white spaces.
public MatchWhiteSpaces ( int minCount = 1 ) : bool
minCount int Minimal number of white spaces to match.
return bool
Ejemplo n.º 1
0
        public virtual bool VisitObjectContent()
        {
            int propertyIndex = 0;

            while (!_m.IsEnd)
            {
                _m.MatchWhiteSpaces(0);
                if (_m.TryMatchChar('}'))
                {
                    return(true);
                }
                int    startPropertyIndex = _m.StartIndex;
                string propName;
                if (!_m.TryMatchJSONQuotedString(out propName))
                {
                    return(false);
                }
                _m.MatchWhiteSpaces(0);
                if (!_m.MatchChar(':') || !VisitObjectProperty(startPropertyIndex, propName, propertyIndex))
                {
                    return(false);
                }
                _m.MatchWhiteSpaces(0);
                _m.TryMatchChar(',');
                ++propertyIndex;
            }
            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Matches a <see cref="LogFilter"/>: it can be a predefined filter as ("Undefined", "Debug", "Verbose", etc.)
        /// or as {GroupLogLevelFilter,LineLogLevelFilter} pairs like "{None,None}", "{Error,Trace}".
        /// </summary>
        /// <param name="m">This <see cref="StringMatcher"/>.</param>
        /// <param name="f">Resulting filter.</param>
        /// <returns>True on success, false on error.</returns>
        public static bool MatchLogFilter(this StringMatcher m, out LogFilter f)
        {
            f = LogFilter.Undefined;
            if (!m.MatchText("Undefined"))
            {
                if (m.MatchText("Debug"))
                {
                    f = LogFilter.Debug;
                }
                else if (m.MatchText("Verbose"))
                {
                    f = LogFilter.Verbose;
                }
                else if (m.MatchText("Monitor"))
                {
                    f = LogFilter.Monitor;
                }
                else if (m.MatchText("Terse"))
                {
                    f = LogFilter.Terse;
                }
                else if (m.MatchText("Release"))
                {
                    f = LogFilter.Release;
                }
                else if (m.MatchText("Off"))
                {
                    f = LogFilter.Off;
                }
                else if (m.MatchText("Invalid"))
                {
                    f = LogFilter.Invalid;
                }
                else
                {
                    int savedIndex = m.StartIndex;

                    if (!m.MatchChar('{'))
                    {
                        return(m.BackwardAddError(savedIndex));
                    }
                    LogLevelFilter group, line;

                    m.MatchWhiteSpaces();
                    if (!m.MatchLogLevelFilter(out group))
                    {
                        return(m.BackwardAddError(savedIndex));
                    }

                    m.MatchWhiteSpaces();
                    if (!m.MatchChar(','))
                    {
                        return(m.BackwardAddError(savedIndex));
                    }

                    m.MatchWhiteSpaces();
                    if (!m.MatchLogLevelFilter(out line))
                    {
                        return(m.BackwardAddError(savedIndex));
                    }
                    m.MatchWhiteSpaces();

                    if (!m.MatchChar('}'))
                    {
                        return(m.BackwardAddError(savedIndex));
                    }
                    f = new LogFilter(group, line);
                }
            }
            return(true);
        }