TupleParser

Namespace: SnowBank.Data.Tuples.Binary · class

Helper class that contains low-level encoders for the tuple binary format

Methods

BeginTuple

static TupleWriter BeginTuple(TupleWriter writer)

Mark the start of a new embedded tuple

EndTuple

static void EndTuple(TupleWriter writer)

Mark the end of an embedded tuple

NumberOfBytes

static int NumberOfBytes(long v)

Returns the minimum number of bytes needed to represent a value

Note: will return 1 even for == 0

static int NumberOfBytes(ulong v)

Returns the minimum number of bytes needed to represent a value

Returns: Note: will return 1 even for == 0

ParseAscii

static string ParseAscii(ReadOnlySpan<byte> slice)

Parse a tuple segment containing an ASCII string stored as a byte array

ParseBytes

static Slice ParseBytes(Slice slice)

Parse a tuple segment containing a byte array

static Slice ParseBytes(ReadOnlySpan<byte> slice)

Parse a tuple segment containing a byte array

ParseDouble

static double ParseDouble(ReadOnlySpan<byte> slice)

Parse a tuple segment containing a double precision number (float64)

ParseEmbeddedTuple

static IVarTuple ParseEmbeddedTuple(Slice slice)

Parse a tuple segment containing an embedded tuple

static SpanTuple ParseEmbeddedTuple(ReadOnlySpan<byte> slice)

Parse a tuple segment containing an embedded tuple

ParseGuid

static Guid ParseGuid(ReadOnlySpan<byte> slice)

Parse a tuple segment containing a 128-bit GUID

ParseInt64

static long ParseInt64(int type, Slice slice)

Parse a tuple segment containing a signed 64-bit integer

This method should only be used by custom decoders.

static long ParseInt64(int type, ReadOnlySpan<byte> slice)

Parse a tuple segment containing a signed 64-bit integer

This method should only be used by custom decoders.

ParseNegativeBigInteger

static BigInteger ParseNegativeBigInteger(ReadOnlySpan<byte> slice)

Parse a tuple segment containing a negative big integer

ParseNegativeInt128

static Int128 ParseNegativeInt128(ReadOnlySpan<byte> slice)

Parse a tuple segment containing a negative big integer into a Int128

ParsePositiveBigInteger

static BigInteger ParsePositiveBigInteger(ReadOnlySpan<byte> slice)

Parse a tuple segment containing a positive big integer

ParsePositiveUInt128

static UInt128 ParsePositiveUInt128(ReadOnlySpan<byte> slice)

Parse a tuple segment containing a positive big integer into a UInt128

ParseQuadruple

static decimal ParseQuadruple(ReadOnlySpan<byte> slice)

Parse a tuple segment containing a quadruple precision floating-point number (aka "binary128")

ParseSingle

static float ParseSingle(ReadOnlySpan<byte> slice)

Parse a tuple segment containing a single precision number (float32)

ParseUInt64

static ulong ParseUInt64(int type, ReadOnlySpan<byte> slice)

Parse a tuple segment containing an unsigned 64-bit integer

This method should only be used by custom decoders.

ParseUtf8

static string ParseUtf8(ReadOnlySpan<byte> slice)

Parse a tuple segment containing a UTF-8 string

ParseUuid128

static Uuid128 ParseUuid128(ReadOnlySpan<byte> slice)

Parse a tuple segment containing a 128-bit UUID

ParseUuid64

static Uuid64 ParseUuid64(ReadOnlySpan<byte> slice)

Parse a tuple segment containing a 64-bit UUID

ParseUuid80

static Uuid80 ParseUuid80(ReadOnlySpan<byte> slice)

Parses a tuple segment containing an 80-bit UUID

ParseUuid96

static Uuid96 ParseUuid96(ReadOnlySpan<byte> slice)

Parses a tuple segment containing an 96-bit UUID

ParseVersionStamp

static VersionStamp ParseVersionStamp(ReadOnlySpan<byte> slice)

Parses a tuple segment containing either an 80-bit or 96-bit VersionStamp

Skip

static bool Skip(ref TupleReader reader, int count)

Skip a number of tokens

  • reader — Cursor in the packed tuple to decode
  • count — Number of tokens to skip

Returns: True if there was count tokens, false if the reader was too small.

Even if this method return true, you need to check that the reader has not reached the end before reading more token!

TryBeginTuple

static bool TryBeginTuple(ref TupleSpanWriter writer)

Opens a new embedded tuple

TryEndTuple

static bool TryEndTuple(ref TupleSpanWriter writer)

Closes an embedded tuple

TryParseAscii

static bool TryParseAscii(ReadOnlySpan<byte> slice, out string value)

Parse a tuple segment containing an ASCII string stored as a byte array

TryParseBytes

static bool TryParseBytes(ReadOnlySpan<byte> slice, out Slice value)

Parse a tuple segment containing a byte array

TryParseDouble

static bool TryParseDouble(ReadOnlySpan<byte> slice, out double value)

Parse a tuple segment containing a double precision number (float64)

TryParseEmbeddedTuple

static bool TryParseEmbeddedTuple(ReadOnlySpan<byte> slice, out SpanTuple value)

Parse a tuple segment containing an embedded tuple

TryParseGuid

static bool TryParseGuid(ReadOnlySpan<byte> slice, out Guid value)

Parse a tuple segment containing a 128-bit GUID

TryParseInt64

static bool TryParseInt64(int type, ReadOnlySpan<byte> slice, out long value)

Parse a tuple segment containing a signed 64-bit integer

This method should only be used by custom decoders.

TryParseNegativeBigInteger

static bool TryParseNegativeBigInteger(ReadOnlySpan<byte> slice, out BigInteger value)

Parse a tuple segment containing a negative big integer

TryParseNext

static bool TryParseNext(ref TupleReader reader, out Range token, out Exception error)

Decode the next token from a packed tuple

Returns: Token decoded, or Slice.Nil if there was no more data in the buffer

TryParsePositiveBigInteger

static bool TryParsePositiveBigInteger(ReadOnlySpan<byte> slice, out BigInteger value)

Parse a tuple segment containing a positive big integer

TryParseQuadruple

static bool TryParseQuadruple(ReadOnlySpan<byte> slice, out decimal value)

Parse a tuple segment containing a quadruple precision floating-point number (aka "binary128")

TryParseSingle

static bool TryParseSingle(ReadOnlySpan<byte> slice, out float value)

Parse a tuple segment containing a single precision number (float32)

TryParseUInt64

static bool TryParseUInt64(int type, ReadOnlySpan<byte> slice, out ulong value)

Parse a tuple segment containing an unsigned 64-bit integer

This method should only be used by custom decoders.

TryParseUtf8

static bool TryParseUtf8(ReadOnlySpan<byte> slice, out string value)

Parse a tuple segment containing a UTF-8 string

TryParseUuid64

static bool TryParseUuid64(ReadOnlySpan<byte> slice, out Uuid64 value)

Parse a tuple segment containing a 64-bit UUID

TryWriteBigInteger

static bool TryWriteBigInteger(ref TupleSpanWriter writer, in BigInteger value)

static bool TryWriteBigInteger(ref TupleSpanWriter writer, in BigInteger? value)

TryWriteBool

static bool TryWriteBool(ref TupleSpanWriter writer, in bool value)

static bool TryWriteBool(ref TupleSpanWriter writer, in bool? value)

TryWriteByte

static bool TryWriteByte(ref TupleSpanWriter writer, in byte value)

Writes an UInt8 at the end, and advance the cursor

  • writer — Target buffer
  • value — Unsigned BYTE, 32 bits

static bool TryWriteByte(ref TupleSpanWriter writer, in byte? value)

TryWriteBytes

static bool TryWriteBytes(ref TupleSpanWriter writer, in byte[] value)

Writes a binary string

static bool TryWriteBytes(ref TupleSpanWriter writer, in ReadOnlyMemory<byte> value)

Writes a binary string

static bool TryWriteBytes(ref TupleSpanWriter writer, in Memory<byte> value)

Writes a binary string

static bool TryWriteBytes(ref TupleSpanWriter writer, in ArraySegment<byte> value)

Writes a binary string

static bool TryWriteBytes(ref TupleSpanWriter writer, in ArraySegment<byte>? value)

Writes a binary string

static bool TryWriteBytes(ref TupleSpanWriter writer, in Slice value)

Writes a binary string

static bool TryWriteBytes(ref TupleSpanWriter writer, in Slice? value)

Writes a binary string

static bool TryWriteBytes(ref TupleSpanWriter writer, in ReadOnlySpan<byte> value)

Writes a binary string

TryWriteChar

static bool TryWriteChar(ref TupleSpanWriter writer, in char value)

Writes a char encoded in UTF-8

static bool TryWriteChar(ref TupleSpanWriter writer, in char? value)

TryWriteDateTime

static bool TryWriteDateTime(ref TupleSpanWriter writer, in DateTime value)

static bool TryWriteDateTime(ref TupleSpanWriter writer, in DateTime? value)

TryWriteDateTimeOffset

static bool TryWriteDateTimeOffset(ref TupleSpanWriter writer, in DateTimeOffset value)

Writes a DateTimeOffset converted to the number of days since the Unix Epoch and stored as a 64-bit decimal

static bool TryWriteDateTimeOffset(ref TupleSpanWriter writer, in DateTimeOffset? value)

TryWriteDouble

static bool TryWriteDouble(ref TupleSpanWriter writer, in double value)

Writes a Double at the end, and advance the cursor

  • writer — Target buffer
  • value — IEEE Floating point, 64 bits, High Endian

static bool TryWriteDouble(ref TupleSpanWriter writer, in double? value)

TryWriteGuid

static bool TryWriteGuid(ref TupleSpanWriter writer, in Guid value)

Writes an RFC 4122 encoded 16-byte Microsoft GUID

static bool TryWriteGuid(ref TupleSpanWriter writer, in Guid? value)

TryWriteInstant

static bool TryWriteInstant(ref TupleSpanWriter writer, in Instant value)

static bool TryWriteInstant(ref TupleSpanWriter writer, in Instant? value)

TryWriteInt16

static bool TryWriteInt16(ref TupleSpanWriter writer, in short value)

static bool TryWriteInt16(ref TupleSpanWriter writer, in short? value)

TryWriteInt32

static bool TryWriteInt32(ref TupleSpanWriter writer, in int value)

Writes an Int32 at the end, and advance the cursor

static bool TryWriteInt32(ref TupleSpanWriter writer, in int? value)

TryWriteInt64

static bool TryWriteInt64(ref TupleSpanWriter writer, in long value)

Writes an Int64 at the end, and advance the cursor

  • writer — Target buffer
  • value — Signed QWORD, 64 bits, High Endian

static bool TryWriteInt64(ref TupleSpanWriter writer, in long? value)

TryWriteIpAddress

static bool TryWriteIpAddress(ref TupleSpanWriter writer, in IPAddress value)

TryWriteNil

static bool TryWriteNil(ref TupleSpanWriter writer)

TryWriteQuadruple

static bool TryWriteQuadruple(ref TupleSpanWriter writer, in decimal value)

static bool TryWriteQuadruple(ref TupleSpanWriter writer, in decimal? value)

TryWriteSByte

static bool TryWriteSByte(ref TupleSpanWriter writer, in sbyte value)

static bool TryWriteSByte(ref TupleSpanWriter writer, in sbyte? value)

TryWriteSingle

static bool TryWriteSingle(ref TupleSpanWriter writer, in float value)

Writes a Single at the end, and advance the cursor

  • writer — Target buffer
  • value — IEEE Floating point, 32 bits, High Endian

static bool TryWriteSingle(ref TupleSpanWriter writer, in float? value)

TryWriteString

static bool TryWriteString(ref TupleSpanWriter writer, in string value)

Writes a string encoded in UTF-8

static bool TryWriteString(ref TupleSpanWriter writer, in ReadOnlyMemory<char> value)

Writes a string encoded in UTF-8

static bool TryWriteString(ref TupleSpanWriter writer, in Memory<char> value)

Writes a string encoded in UTF-8

static bool TryWriteString(ref TupleSpanWriter writer, ReadOnlySpan<char> value)

Writes a string encoded in UTF-8

TryWriteTimeSpan

static bool TryWriteTimeSpan(ref TupleSpanWriter writer, in TimeSpan value)

static bool TryWriteTimeSpan(ref TupleSpanWriter writer, in TimeSpan? value)

TryWriteUInt16

static bool TryWriteUInt16(ref TupleSpanWriter writer, in ushort value)

static bool TryWriteUInt16(ref TupleSpanWriter writer, in ushort? value)

TryWriteUInt32

static bool TryWriteUInt32(ref TupleSpanWriter writer, in uint value)

Writes an UInt32 at the end, and advance the cursor

  • writer — Target buffer
  • value — Signed DWORD, 32 bits, High Endian

static bool TryWriteUInt32(ref TupleSpanWriter writer, in uint? value)

TryWriteUInt64

static bool TryWriteUInt64(ref TupleSpanWriter writer, in ulong value)

Writes an UInt64 at the end, and advance the cursor

  • writer — Target buffer
  • value — Signed QWORD, 64 bits, High Endian

static bool TryWriteUInt64(ref TupleSpanWriter writer, in ulong? value)

TryWriteUserType

static bool TryWriteUserType(ref TupleSpanWriter writer, in TuPackUserType value)

TryWriteUuid128

static bool TryWriteUuid128(ref TupleSpanWriter writer, in Uuid128 value)

Writes an RFC 4122 encoded 128-bit UUID

static bool TryWriteUuid128(ref TupleSpanWriter writer, in Uuid128? value)

TryWriteUuid48

static bool TryWriteUuid48(ref TupleSpanWriter writer, in Uuid48 value)

Writes a 48-bit UUID

static bool TryWriteUuid48(ref TupleSpanWriter writer, in Uuid48? value)

TryWriteUuid64

static bool TryWriteUuid64(ref TupleSpanWriter writer, in Uuid64 value)

Writes a 64-bit UUID

static bool TryWriteUuid64(ref TupleSpanWriter writer, in Uuid64? value)

TryWriteUuid80

static bool TryWriteUuid80(ref TupleSpanWriter writer, in Uuid80 value)

Writes an 80-bit UUID

static bool TryWriteUuid80(ref TupleSpanWriter writer, in Uuid80? value)

TryWriteUuid96

static bool TryWriteUuid96(ref TupleSpanWriter writer, in Uuid96 value)

Writes a 96-bit UUID

static bool TryWriteUuid96(ref TupleSpanWriter writer, in Uuid96? value)

TryWriteVersionStamp

static bool TryWriteVersionStamp(ref TupleSpanWriter writer, in VersionStamp value)

static bool TryWriteVersionStamp(ref TupleSpanWriter writer, in VersionStamp? value)

VisitNext

static T VisitNext<T>(ref TupleReader reader, Func<ReadOnlySpan<byte>, TupleSegmentType, T> visitor)

Visit the different tokens of a packed tuple

  • reader — Reader positioned at the start of a packed tuple
  • visitor — Lambda called for each segment of a tuple. Returns true to continue parsing, or false to stop

Returns: Number of tokens that have been visited until either visitor returned false, or reader reached the end.

WriteBigInteger

static void WriteBigInteger(TupleWriter writer, BigInteger value)

static void WriteBigInteger(TupleWriter writer, BigInteger? value)

WriteBool

static void WriteBool(TupleWriter writer, bool value)

static void WriteBool(TupleWriter writer, bool? value)

WriteByte

static void WriteByte(TupleWriter writer, byte value)

Writes an UInt8 at the end, and advance the cursor

  • writer — Target buffer
  • value — Unsigned BYTE, 32 bits

static void WriteByte(TupleWriter writer, byte? value)

WriteBytes

static void WriteBytes(TupleWriter writer, byte[] value)

Writes a binary string

static void WriteBytes(TupleWriter writer, ReadOnlyMemory<byte> value)

Writes a binary string

static void WriteBytes(TupleWriter writer, Memory<byte> value)

Writes a binary string

static void WriteBytes(TupleWriter writer, ArraySegment<byte> value)

Writes a binary string

static void WriteBytes(TupleWriter writer, ArraySegment<byte>? value)

Writes a binary string

static void WriteBytes(TupleWriter writer, Slice value)

Writes a binary string

static void WriteBytes(TupleWriter writer, Slice? value)

Writes a binary string

static void WriteBytes(TupleWriter writer, ReadOnlySpan<byte> value)

Writes a binary string

WriteChar

static void WriteChar(TupleWriter writer, char value)

Writes a char encoded in UTF-8

static void WriteChar(TupleWriter writer, char? value)

WriteDateTime

static void WriteDateTime(TupleWriter writer, DateTime value)

static void WriteDateTime(TupleWriter writer, DateTime? value)

WriteDateTimeOffset

static void WriteDateTimeOffset(TupleWriter writer, DateTimeOffset value)

Writes a DateTimeOffset converted to the number of days since the Unix Epoch and stored as a 64-bit decimal

static void WriteDateTimeOffset(TupleWriter writer, DateTimeOffset? value)

WriteDouble

static void WriteDouble(TupleWriter writer, double value)

Writes a Double at the end, and advance the cursor

  • writer — Target buffer
  • value — IEEE Floating point, 64 bits, High Endian

static void WriteDouble(TupleWriter writer, double? value)

WriteGuid

static void WriteGuid(TupleWriter writer, Guid value)

Writes an RFC 4122 encoded 16-byte Microsoft GUID

static void WriteGuid(TupleWriter writer, Guid? value)

WriteInstant

static void WriteInstant(TupleWriter writer, Instant value)

static void WriteInstant(TupleWriter writer, Instant? value)

WriteInt128

static void WriteInt128(TupleWriter writer, Int128 value)

static void WriteInt128(TupleWriter writer, Int128? value)

WriteInt16

static void WriteInt16(TupleWriter writer, short value)

static void WriteInt16(TupleWriter writer, short? value)

WriteInt32

static void WriteInt32(TupleWriter writer, int value)

Writes an Int32 at the end, and advance the cursor

  • writer — Target buffer
  • value — Signed DWORD, 32 bits, High Endian

static void WriteInt32(TupleWriter writer, int? value)

WriteInt64

static void WriteInt64(TupleWriter writer, long value)

Writes an Int64 at the end, and advance the cursor

  • writer — Target buffer
  • value — Signed QWORD, 64 bits, High Endian

static void WriteInt64(TupleWriter writer, long? value)

WriteIpAddress

static void WriteIpAddress(TupleWriter writer, IPAddress value)

WriteNil

static void WriteNil(TupleWriter writer)

Writes a null value at the end, and advance the cursor

WriteQuadruple

static void WriteQuadruple(TupleWriter writer, decimal value)

static void WriteQuadruple(TupleWriter writer, decimal? value)

WriteSByte

static void WriteSByte(TupleWriter writer, sbyte value)

static void WriteSByte(TupleWriter writer, sbyte? value)

WriteSingle

static void WriteSingle(TupleWriter writer, float value)

Writes a Single at the end, and advance the cursor

  • writer — Target buffer
  • value — IEEE Floating point, 32 bits, High Endian

static void WriteSingle(TupleWriter writer, float? value)

WriteString

static void WriteString(TupleWriter writer, string value)

Writes a string encoded in UTF-8

static void WriteString(TupleWriter writer, ReadOnlyMemory<char> value)

Writes a string encoded in UTF-8

static void WriteString(TupleWriter writer, Memory<char> value)

Writes a string encoded in UTF-8

static void WriteString(TupleWriter writer, ReadOnlySpan<char> value)

Writes a string encoded in UTF-8

WriteTimeSpan

static void WriteTimeSpan(TupleWriter writer, TimeSpan value)

static void WriteTimeSpan(TupleWriter writer, TimeSpan? value)

WriteUInt128

static void WriteUInt128(TupleWriter writer, UInt128 value)

static void WriteUInt128(TupleWriter writer, UInt128? value)

WriteUInt16

static void WriteUInt16(TupleWriter writer, ushort value)

static void WriteUInt16(TupleWriter writer, ushort? value)

WriteUInt32

static void WriteUInt32(TupleWriter writer, uint value)

Writes an UInt32 at the end, and advance the cursor

  • writer — Target buffer
  • value — Signed DWORD, 32 bits, High Endian

static void WriteUInt32(TupleWriter writer, uint? value)

WriteUInt64

static void WriteUInt64(TupleWriter writer, ulong value)

Writes an UInt64 at the end, and advance the cursor

  • writer — Target buffer
  • value — Signed QWORD, 64 bits, High Endian

static void WriteUInt64(TupleWriter writer, ulong? value)

WriteUserType

static void WriteUserType(TupleWriter writer, TuPackUserType value)

WriteUuid128

static void WriteUuid128(TupleWriter writer, Uuid128 value)

Writes an RFC 4122 encoded 128-bit UUID

static void WriteUuid128(TupleWriter writer, Uuid128? value)

WriteUuid48

static void WriteUuid48(TupleWriter writer, Uuid48 value)

Writes a 48-bit UUID

static void WriteUuid48(TupleWriter writer, Uuid48? value)

WriteUuid64

static void WriteUuid64(TupleWriter writer, Uuid64 value)

Writes a 64-bit UUID

static void WriteUuid64(TupleWriter writer, Uuid64? value)

WriteUuid80

static void WriteUuid80(TupleWriter writer, Uuid80 value)

Writes an 80-bit UUID

static void WriteUuid80(TupleWriter writer, Uuid80? value)

WriteUuid96

static void WriteUuid96(TupleWriter writer, Uuid96 value)

Writes a 96-bit UUID

static void WriteUuid96(TupleWriter writer, Uuid96? value)

WriteVersionStamp

static void WriteVersionStamp(TupleWriter writer, VersionStamp value)

static void WriteVersionStamp(TupleWriter writer, VersionStamp? value)