withSIX.Play.Core.Games.Legacy.Steam.KeyValuesTokenizer.NextToken C# (CSharp) Method

NextToken() public method

public NextToken ( ) : string>.Tuple
return string>.Tuple
        public Tuple<TokenType, string> NextToken() {
            while (true) {
                IgnoreWhitespace();
                if (!IgnoreComment())
                    break;
            }

            var current = Current();
            if (current == default(char))
                return null;

            if (current == '{') {
                Forward();
                return Tuple.Create(TokenType.BlockBegin, (string) null);
            }
            if (current == '}') {
                Forward();
                return Tuple.Create(TokenType.BlockEnd, (string) null);
            }
            return Tuple.Create(TokenType.String, GetString());
        }

Usage Example

コード例 #1
0
        public void Load(string data)
        {
            var tokenizer = new KeyValuesTokenizer(data);
            var token     = tokenizer.NextToken();

            if (token == null || token.Item1 != TokenType.String)
            {
                throw new ParseException("Invalid token at " + tokenizer.Location());
            }

            var key = token.Item2;

            token = tokenizer.NextToken();
            if (token == null || token.Item1 != TokenType.BlockBegin)
            {
                throw new ParseException($"Invalid token: {token.Item1}, {token.Item2} at {tokenizer.Location()}");
            }

            var kv = new KeyValues();

            this[key] = kv;
            kv.Parse(tokenizer);

            token = tokenizer.NextToken();
            if (token != null)
            {
                throw new ParseException("Unexpected token at file end");
            }
        }
All Usage Examples Of withSIX.Play.Core.Games.Legacy.Steam.KeyValuesTokenizer::NextToken