decoder

package
v0.0.0-...-e3369bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadBigInt

func ReadBigInt(inputSource *bytes.Buffer) (value.BigInt, error)

ReadBigInt reads the next FAST encoded value off the inputSource, treating it as an int64 value. However, this value may overflow an int64 by 1 byte (for delta encoding) and therefore we can return a value.BigInt if this happens. The least significant byte is in the overflow value. If the next value would till overflow this structure an err is returned.

func ReadBigUInt

func ReadBigUInt(inputSource *bytes.Buffer) (value.BigInt, error)

ReadBigUInt reads the next FAST encoded value off the inputSource, treating it as an uint64 value. However, this value may overflow an uint64 by 1 byte (for delta encoding) and therefore we can return a value.BigInt if this happens. The least significant byte is in the overflow value. If the next value would till overflow this structure an err is returned.

func ReadByteVector

func ReadByteVector(inputSource *bytes.Buffer) (value.ByteVector, error)

ReadByteVector reads a uint32 length off the buffer which represents the length of the vector to then read. The vector read is not stop bit encoded. i.e. 10000010 00000001 00000010 would become (length 2) -> [1, 2]

func ReadInt32

func ReadInt32(inputSource *bytes.Buffer) (value.Int32Value, error)

ReadInt32 reads the next FAST encoded value off the inputSource, treating it as an int32 value (2's compliment encoded). If the next value would overflow an int32 an err is returned. i.e. 11111111 01001110 would become 11111111001110 -> 11001110 -> -50

func ReadInt64

func ReadInt64(inputSource *bytes.Buffer) (value.Int64Value, error)

ReadInt64 reads the next FAST encoded value off the inputSource, treating it as an int64 value (2's compliment encoded). If the next value would overflow an int64 an err is returned. i.e. 11111111 01001110 would become 11111111001110 -> 11001110 -> -50

func ReadOptionalBigInt

func ReadOptionalBigInt(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalBigInt reads a value.BigInt off the input buffer. If the value returned is 0, this is marked as nil, and nil is returned. Due to needing to use 0 as a nil value for optionals, the value returned by this is: value - 1 for positive numbers only.

func ReadOptionalByteVector

func ReadOptionalByteVector(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalByteVector treats the uint32 length preamble as an optional uint32, reading 0 as a null marker. The byte vector itself is read as long as the length is not null. i.e. 10000010 00000001 would become (length 1) -> [1] i.e. 10000000 would become 0, and be marked as null

func ReadOptionalInt32

func ReadOptionalInt32(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalInt32 reads an int32 off the buffer. If the value returned is 0, this is marked as nil, and nil is returned. Due to needing to use 0 as a nil value for optionals, the value returned by this is: value - 1 for positive numbers only. i.e. 10000000 would become nil, 10000001 would become 0

func ReadOptionalInt64

func ReadOptionalInt64(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalInt64 reads an int64 off the buffer. If the value returned is 0, this is marked as nil, and nil is returned. Due to needing to use 0 as a nil value for optionals, the value returned by this is: value - 1 for positive numbers only. i.e. 10000000 would become nil, 10000001 would become 0

func ReadOptionalString

func ReadOptionalString(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalString reads an ASCII encoded string off the buffer. If the first value is 10000000, this is seen as null. If the first values are 00000000 10000000 this is seen as an empty string.

func ReadOptionalUInt32

func ReadOptionalUInt32(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalUInt32 reads a uint32 off the buffer. If the value returned is 0, this is marked as nil, and nil is returned. Due to needing to use 0 as a nil value for optionals, the value returned by this is: value - 1. i.e. 10000000 would become nil, 10000001 would become 0

func ReadOptionalUInt64

func ReadOptionalUInt64(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalUInt64 reads a uint64 off the buffer. If the value returned is 0, this is marked as nil, and nil is returned. Due to needing to use 0 as a nil value for optionals, the value returned by this is: value - 1. i.e. 10000000 would become nil, 10000001 would become 0

func ReadString

func ReadString(inputSource *bytes.Buffer) (value.StringValue, error)

ReadString reads an ASCII encoded string off the buffer. This can be done as ASCII is a subset of UTF-8 which is what GO uses to represent strings.

func ReadUInt32

func ReadUInt32(inputSource *bytes.Buffer) (value.UInt32Value, error)

ReadUInt32 reads the next FAST encoded value off the inputSource, treating it as a uint32 value. If the next value would overflow a uint32 an err is returned. i.e. 00010010 10001000 would become 100100001000

func ReadUInt64

func ReadUInt64(inputSource *bytes.Buffer) (value.UInt64Value, error)

ReadUInt64 reads the next FAST encoded value off the inputSource, treating it as a uint64 value. If the next value would overflow a uint64 an err is returned. i.e. 00010010 10001000 would become 100100001000

func ReadValue

func ReadValue(inputSource *bytes.Buffer) ([]byte, error)

ReadValue reads the values off the byte buffer until a stop but is detected. Stop bits are not removed from the bytes returned.

Types

type AsciiStringDecoder

type AsciiStringDecoder struct {
}

AsciiStringDecoder performs a read/optional read of a FAST encoded string

func (AsciiStringDecoder) ReadOptionalValue

func (AsciiStringDecoder) ReadOptionalValue(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalValue fast encoded optional string

func (AsciiStringDecoder) ReadValue

func (AsciiStringDecoder) ReadValue(inputSource *bytes.Buffer) (value.Value, error)

ReadValue fast encoded string

type AsciiStringDeltaDecoder

type AsciiStringDeltaDecoder struct {
}

AsciiStringDeltaDecoder performs a read/optional read of a FAST encoded string delta

func (AsciiStringDeltaDecoder) ReadOptionalValue

func (AsciiStringDeltaDecoder) ReadOptionalValue(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalValue fast encoded string delta

func (AsciiStringDeltaDecoder) ReadValue

func (AsciiStringDeltaDecoder) ReadValue(inputSource *bytes.Buffer) (value.Value, error)

ReadValue fast encoded string delta

type BitIntDecoder

type BitIntDecoder struct {
}

BitIntDecoder performs a read/optional read of a FAST encoded int64 with allowed overflow of a single byte

func (BitIntDecoder) ReadOptionalValue

func (BitIntDecoder) ReadOptionalValue(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalValue fast encoded optional int64 with allowed overflow

func (BitIntDecoder) ReadValue

func (BitIntDecoder) ReadValue(inputSource *bytes.Buffer) (value.Value, error)

ReadValue fast encoded int64 with allowed overflow

type ByteVectorDecoder

type ByteVectorDecoder struct {
}

ByteVectorDecoder performs a read/optional read of a FAST encoded byte vector

func (ByteVectorDecoder) ReadOptionalValue

func (ByteVectorDecoder) ReadOptionalValue(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalValue fast encoded byte vector

func (ByteVectorDecoder) ReadValue

func (ByteVectorDecoder) ReadValue(inputSource *bytes.Buffer) (value.Value, error)

ReadValue fast encoded byte vector

type ByteVectorDeltaDecoder

type ByteVectorDeltaDecoder struct {
}

ByteVectorDeltaDecoder performs a read/optional read of a FAST encoded byte vector delta

func (ByteVectorDeltaDecoder) ReadOptionalValue

func (ByteVectorDeltaDecoder) ReadOptionalValue(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalValue fast encoded byte vector delta

func (ByteVectorDeltaDecoder) ReadValue

func (ByteVectorDeltaDecoder) ReadValue(inputSource *bytes.Buffer) (value.Value, error)

ReadValue fast encoded byte vector delta

type Decoder

type Decoder interface {
	ReadValue(inputSource *bytes.Buffer) (value.Value, error)
	ReadOptionalValue(inputSource *bytes.Buffer) (value.Value, error)
}

Decoder is used to couple the reading of required and optional values of the same type

type Int32Decoder

type Int32Decoder struct {
}

Int32Decoder performs a read/optional read of a FAST encoded int32

func (Int32Decoder) ReadOptionalValue

func (Int32Decoder) ReadOptionalValue(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalValue fast encoded optional int32

func (Int32Decoder) ReadValue

func (Int32Decoder) ReadValue(inputSource *bytes.Buffer) (value.Value, error)

ReadValue fast encoded int32

type Int64Decoder

type Int64Decoder struct {
}

Int64Decoder performs a read/optional read of a FAST encoded int64

func (Int64Decoder) ReadOptionalValue

func (Int64Decoder) ReadOptionalValue(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalValue fast encoded optional int64

func (Int64Decoder) ReadValue

func (Int64Decoder) ReadValue(inputSource *bytes.Buffer) (value.Value, error)

ReadValue fast encoded int64

type UInt32Decoder

type UInt32Decoder struct {
}

UInt32Decoder performs a read/optional read of a FAST encoded uint32

func (UInt32Decoder) ReadOptionalValue

func (UInt32Decoder) ReadOptionalValue(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalValue fast encoded optional uint32

func (UInt32Decoder) ReadValue

func (UInt32Decoder) ReadValue(inputSource *bytes.Buffer) (value.Value, error)

ReadValue fast encoded uint32

type UInt64Decoder

type UInt64Decoder struct {
}

UInt64Decoder performs a read/optional read of a FAST encoded uint64

func (UInt64Decoder) ReadOptionalValue

func (UInt64Decoder) ReadOptionalValue(inputSource *bytes.Buffer) (value.Value, error)

ReadOptionalValue fast encoded optional uint64

func (UInt64Decoder) ReadValue

func (UInt64Decoder) ReadValue(inputSource *bytes.Buffer) (value.Value, error)

ReadValue fast encoded uint64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL