<PackageReference Include="Google.Protobuf" Version="3.35.1" />

Google.Protobuf.ParsingPrimitives

static class ParsingPrimitives
Primitives for parsing protobuf wire format.
public static int DecodeZigZag32(uint n)

Decode a 32-bit value with ZigZag encoding.

public static long DecodeZigZag64(ulong n)

Decode a 64-bit value with ZigZag encoding.

public static bool IsDataAvailable(ref ParserInternalState state, int size)

Checks whether there is known data available of the specified size remaining to parse. When parsing from a Stream this can return false because we have no knowledge of the amount of data remaining in the stream until it is read.

public static bool MaybeConsumeTag(ref ReadOnlySpan buffer, ref ParserInternalState state, uint tag)

Peeks at the next tag in the stream. If it matches tag, the tag is consumed and the method returns true; otherwise, the stream is left in the original position and the method returns false.

public static double ParseDouble(ref ReadOnlySpan buffer, ref ParserInternalState state)

Parses a double value.

public static float ParseFloat(ref ReadOnlySpan buffer, ref ParserInternalState state)

Parses a float value.

public static int ParseLength(ref ReadOnlySpan buffer, ref ParserInternalState state)

Reads a length for length-delimited data.

public static uint ParseRawLittleEndian32(ref ReadOnlySpan buffer, ref ParserInternalState state)

Parses a 32-bit little-endian integer.

public static ulong ParseRawLittleEndian64(ref ReadOnlySpan buffer, ref ParserInternalState state)

Parses a 64-bit little-endian integer.

public static uint ParseRawVarint32(ref ReadOnlySpan buffer, ref ParserInternalState state)

Parses a raw Varint. If larger than 32 bits, discard the upper bits. This method is optimised for the case where we've got lots of data in the buffer. That means we can check the size just once, then just read directly from the buffer without constant rechecking of the buffer length.

public static ulong ParseRawVarint64(ref ReadOnlySpan buffer, ref ParserInternalState state)

Parses a raw varint.

public static uint ParseTag(ref ReadOnlySpan buffer, ref ParserInternalState state)

Parses the next tag. If the end of logical stream was reached, an invalid tag of 0 is returned.

public static uint PeekTag(ref ReadOnlySpan buffer, ref ParserInternalState state)

Peeks at the next field tag. This is like calling ParseTag, but the tag is not consumed. (So a subsequent call to ParseTag will return the same value.)

public static ByteString ReadBytes(ref ReadOnlySpan buffer, ref ParserInternalState state)

Reads a bytes field value from the input.

public static byte[] ReadRawBytes(ref ReadOnlySpan buffer, ref ParserInternalState state, int size)

Reads a fixed size of bytes from the input.

public static string ReadRawString(ref ReadOnlySpan buffer, ref ParserInternalState state, int length)

Reads a UTF-8 string from the next "length" bytes.

public static uint ReadRawVarint32(Stream input)

Reads a varint from the input one byte at a time, so that it does not read any bytes after the end of the varint. If you simply wrapped the stream in a CodedInputStream and used ReadRawVarint32(Stream) then you would probably end up reading past the end of the varint since CodedInputStream buffers its input.

public static string ReadString(ref ReadOnlySpan buffer, ref ParserInternalState state)

Reads a string field value from the input.

public static void SkipRawBytes(ref ReadOnlySpan buffer, ref ParserInternalState state, int size)

Reads and discards size bytes.