Beispiel #1
0
        // TODO: how to we chose the lengths of the temp buffers?
        // TODO: these methods call the slow overloads of Parsers.Custom.TryParseXXX. Do we need fast path?
        // TODO: these methods hardcode the format. Do we need this to be something that can be specified?
        public bool TryParseBoolean(out bool value)
        {
            var unread = Unread;

            if (CustomParser.TryParseBoolean(unread, out value, out int consumed, _symbolTable))
            {
                Debug.Assert(consumed <= unread.Length);
                if (unread.Length > consumed)
                {
                    _currentSegmentIndex += consumed;
                    _index += consumed;
                    return(true);
                }
            }

            Span <byte> tempSpan = stackalloc byte[15];
            var         copied   = CopyTo(tempSpan);

            if (CustomParser.TryParseBoolean(tempSpan.Slice(0, copied), out value, out consumed, _symbolTable))
            {
                Advance(consumed);
                return(true);
            }

            return(false);
        }
Beispiel #2
0
        public bool TryParseUInt64(out ulong value)
        {
            var unread = Unread;

            if (CustomParser.TryParseUInt64(unread, out value, out int consumed, default, _symbolTable))