public static void SkipLastField(ref ReadOnlySpan <byte> buffer, ref ParserInternalState state)
        {
            if (state.lastTag == 0)
            {
                throw new InvalidOperationException("SkipLastField cannot be called at the end of a stream");
            }
            switch (WireFormat.GetTagWireType(state.lastTag))
            {
            case WireFormat.WireType.StartGroup:
                SkipGroup(ref buffer, ref state, state.lastTag);
                break;

            case WireFormat.WireType.EndGroup:
                throw new InvalidProtocolBufferException(
                          "SkipLastField called on an end-group tag, indicating that the corresponding start-group was missing");

            case WireFormat.WireType.Fixed32:
                ParsingPrimitives.ParseRawLittleEndian32(ref buffer, ref state);
                break;

            case WireFormat.WireType.Fixed64:
                ParsingPrimitives.ParseRawLittleEndian64(ref buffer, ref state);
                break;

            case WireFormat.WireType.LengthDelimited:
                var length = ParsingPrimitives.ParseLength(ref buffer, ref state);
                ParsingPrimitives.SkipRawBytes(ref buffer, ref state, length);
                break;

            case WireFormat.WireType.Varint:
                ParsingPrimitives.ParseRawVarint32(ref buffer, ref state);
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads a 32-bit little-endian integer from the stream.
        /// </summary>
        internal uint ReadRawLittleEndian32()
        {
            var span = new ReadOnlySpan <byte>(buffer);

            return(ParsingPrimitives.ParseRawLittleEndian32(ref span, ref state));
        }
Ejemplo n.º 3
0
 public int ReadSFixed32()
 {
     return((int)ParsingPrimitives.ParseRawLittleEndian32(ref buffer, ref state));
 }