flatbuffers

package
Version: v22.11.23+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: Apache-2.0 Imports: 3 Imported by: 766

Documentation

Overview

Package flatbuffers provides facilities to read and write flatbuffers objects.

Index

Constants

View Source
const (

	// SizeUint8 is the byte size of a uint8.
	SizeUint8 = 1
	// SizeUint16 is the byte size of a uint16.
	SizeUint16 = 2
	// SizeUint32 is the byte size of a uint32.
	SizeUint32 = 4
	// SizeUint64 is the byte size of a uint64.
	SizeUint64 = 8

	// SizeInt8 is the byte size of a int8.
	SizeInt8 = 1
	// SizeInt16 is the byte size of a int16.
	SizeInt16 = 2
	// SizeInt32 is the byte size of a int32.
	SizeInt32 = 4
	// SizeInt64 is the byte size of a int64.
	SizeInt64 = 8

	// SizeFloat32 is the byte size of a float32.
	SizeFloat32 = 4
	// SizeFloat64 is the byte size of a float64.
	SizeFloat64 = 8

	// SizeByte is the byte size of a byte.
	// The `byte` type is aliased (by Go definition) to uint8.
	SizeByte = 1

	// SizeBool is the byte size of a bool.
	// The `bool` type is aliased (by flatbuffers convention) to uint8.
	SizeBool = 1

	// SizeSOffsetT is the byte size of an SOffsetT.
	// The `SOffsetT` type is aliased (by flatbuffers convention) to int32.
	SizeSOffsetT = 4
	// SizeUOffsetT is the byte size of an UOffsetT.
	// The `UOffsetT` type is aliased (by flatbuffers convention) to uint32.
	SizeUOffsetT = 4
	// SizeVOffsetT is the byte size of an VOffsetT.
	// The `VOffsetT` type is aliased (by flatbuffers convention) to uint16.
	SizeVOffsetT = 2
)
View Source
const (
	// VtableMetadataFields is the count of metadata fields in each vtable.
	VtableMetadataFields = 2
)

Variables

View Source
var Codec = "flatbuffers"

Codec implements gRPC-go Codec which is used to encode and decode messages.

Functions

func GetBool

func GetBool(buf []byte) bool

GetBool decodes a little-endian bool from a byte slice.

func GetByte

func GetByte(buf []byte) byte

GetByte decodes a little-endian byte from a byte slice.

func GetFloat32

func GetFloat32(buf []byte) float32

GetFloat32 decodes a little-endian float32 from a byte slice.

func GetFloat64

func GetFloat64(buf []byte) float64

GetFloat64 decodes a little-endian float64 from a byte slice.

func GetInt16

func GetInt16(buf []byte) (n int16)

GetInt16 decodes a little-endian int16 from a byte slice.

func GetInt32

func GetInt32(buf []byte) (n int32)

GetInt32 decodes a little-endian int32 from a byte slice.

func GetInt64

func GetInt64(buf []byte) (n int64)

GetInt64 decodes a little-endian int64 from a byte slice.

func GetInt8

func GetInt8(buf []byte) (n int8)

GetInt8 decodes a little-endian int8 from a byte slice.

func GetRootAs added in v1.5.0

func GetRootAs(buf []byte, offset UOffsetT, fb FlatBuffer)

GetRootAs is a generic helper to initialize a FlatBuffer with the provided buffer bytes and its data offset.

func GetSizePrefix

func GetSizePrefix(buf []byte, offset UOffsetT) uint32

GetSizePrefix reads the size from a size-prefixed flatbuffer

func GetSizePrefixedRootAs

func GetSizePrefixedRootAs(buf []byte, offset UOffsetT, fb FlatBuffer)

GetSizePrefixedRootAs is a generic helper to initialize a FlatBuffer with the provided size-prefixed buffer bytes and its data offset

func GetUint16

func GetUint16(buf []byte) (n uint16)

GetUint16 decodes a little-endian uint16 from a byte slice.

func GetUint32

func GetUint32(buf []byte) (n uint32)

GetUint32 decodes a little-endian uint32 from a byte slice.

func GetUint64

func GetUint64(buf []byte) (n uint64)

GetUint64 decodes a little-endian uint64 from a byte slice.

func GetUint8

func GetUint8(buf []byte) (n uint8)

GetUint8 decodes a little-endian uint8 from a byte slice.

func WriteBool

func WriteBool(buf []byte, b bool)

WriteBool encodes a little-endian bool into a byte slice.

func WriteByte

func WriteByte(buf []byte, n byte)

WriteByte encodes a little-endian uint8 into a byte slice.

func WriteFloat32

func WriteFloat32(buf []byte, n float32)

WriteFloat32 encodes a little-endian float32 into a byte slice.

func WriteFloat64

func WriteFloat64(buf []byte, n float64)

WriteFloat64 encodes a little-endian float64 into a byte slice.

func WriteInt16

func WriteInt16(buf []byte, n int16)

WriteInt16 encodes a little-endian int16 into a byte slice.

func WriteInt32

func WriteInt32(buf []byte, n int32)

WriteInt32 encodes a little-endian int32 into a byte slice.

func WriteInt64

func WriteInt64(buf []byte, n int64)

WriteInt64 encodes a little-endian int64 into a byte slice.

func WriteInt8

func WriteInt8(buf []byte, n int8)

WriteInt8 encodes a little-endian int8 into a byte slice.

func WriteSOffsetT

func WriteSOffsetT(buf []byte, n SOffsetT)

WriteSOffsetT encodes a little-endian SOffsetT into a byte slice.

func WriteUOffsetT

func WriteUOffsetT(buf []byte, n UOffsetT)

WriteUOffsetT encodes a little-endian UOffsetT into a byte slice.

func WriteUint16

func WriteUint16(buf []byte, n uint16)

WriteUint16 encodes a little-endian uint16 into a byte slice.

func WriteUint32

func WriteUint32(buf []byte, n uint32)

WriteUint32 encodes a little-endian uint32 into a byte slice.

func WriteUint64

func WriteUint64(buf []byte, n uint64)

WriteUint64 encodes a little-endian uint64 into a byte slice.

func WriteUint8

func WriteUint8(buf []byte, n uint8)

WriteUint8 encodes a little-endian uint8 into a byte slice.

func WriteVOffsetT

func WriteVOffsetT(buf []byte, n VOffsetT)

WriteVOffsetT encodes a little-endian VOffsetT into a byte slice.

Types

type Builder

type Builder struct {
	// `Bytes` gives raw access to the buffer. Most users will want to use
	// FinishedBytes() instead.
	Bytes []byte
	// contains filtered or unexported fields
}

Builder is a state machine for creating FlatBuffer objects. Use a Builder to construct object(s) starting from leaf nodes.

A Builder constructs byte buffers in a last-first manner for simplicity and performance.

func NewBuilder

func NewBuilder(initialSize int) *Builder

NewBuilder initializes a Builder of size `initial_size`. The internal buffer is grown as needed.

func (*Builder) CreateByteString added in v1.2.0

func (b *Builder) CreateByteString(s []byte) UOffsetT

CreateByteString writes a byte slice as a string (null-terminated).

func (*Builder) CreateByteVector added in v1.1.0

func (b *Builder) CreateByteVector(v []byte) UOffsetT

CreateByteVector writes a ubyte vector

func (*Builder) CreateSharedString added in v1.12.0

func (b *Builder) CreateSharedString(s string) UOffsetT

CreateSharedString Checks if the string is already written to the buffer before calling CreateString

func (*Builder) CreateString

func (b *Builder) CreateString(s string) UOffsetT

CreateString writes a null-terminated string as a vector.

func (*Builder) CreateVectorOfSortedTables

func (b *Builder) CreateVectorOfSortedTables(offsets []UOffsetT, keyCompare KeyCompare) UOffsetT

func (*Builder) CreateVectorOfTables

func (b *Builder) CreateVectorOfTables(offsets []UOffsetT) UOffsetT

CreateVectorOfTables serializes slice of table offsets into a vector.

func (*Builder) EndObject

func (b *Builder) EndObject() UOffsetT

EndObject writes data necessary to finish object construction.

func (*Builder) EndVector

func (b *Builder) EndVector(vectorNumElems int) UOffsetT

EndVector writes data necessary to finish vector construction.

func (*Builder) Finish

func (b *Builder) Finish(rootTable UOffsetT)

Finish finalizes a buffer, pointing to the given `rootTable`.

func (*Builder) FinishSizePrefixed

func (b *Builder) FinishSizePrefixed(rootTable UOffsetT)

FinishSizePrefixed finalizes a buffer, pointing to the given `rootTable`. The buffer is prefixed with the size of the buffer, excluding the size of the prefix itself.

func (*Builder) FinishSizePrefixedWithFileIdentifier

func (b *Builder) FinishSizePrefixedWithFileIdentifier(rootTable UOffsetT, fid []byte)

FinishSizePrefixedWithFileIdentifier finalizes a buffer, pointing to the given `rootTable` and applies a file identifier. The buffer is prefixed with the size of the buffer, excluding the size of the prefix itself.

func (*Builder) FinishWithFileIdentifier added in v1.10.0

func (b *Builder) FinishWithFileIdentifier(rootTable UOffsetT, fid []byte)

FinishWithFileIdentifier finalizes a buffer, pointing to the given `rootTable`. as well as applys a file identifier

func (*Builder) FinishedBytes added in v1.3.0

func (b *Builder) FinishedBytes() []byte

FinishedBytes returns a pointer to the written data in the byte buffer. Panics if the builder is not in a finished state (which is caused by calling `Finish()`).

func (*Builder) Head

func (b *Builder) Head() UOffsetT

Head gives the start of useful data in the underlying byte buffer. Note: unlike other functions, this value is interpreted as from the left.

func (*Builder) Offset

func (b *Builder) Offset() UOffsetT

Offset relative to the end of the buffer.

func (*Builder) Pad

func (b *Builder) Pad(n int)

Pad places zeros at the current offset.

func (*Builder) PlaceBool

func (b *Builder) PlaceBool(x bool)

PlaceBool prepends a bool to the Builder, without checking for space.

func (*Builder) PlaceByte

func (b *Builder) PlaceByte(x byte)

PlaceByte prepends a byte to the Builder, without checking for space.

func (*Builder) PlaceFloat32

func (b *Builder) PlaceFloat32(x float32)

PlaceFloat32 prepends a float32 to the Builder, without checking for space.

func (*Builder) PlaceFloat64

func (b *Builder) PlaceFloat64(x float64)

PlaceFloat64 prepends a float64 to the Builder, without checking for space.

func (*Builder) PlaceInt16

func (b *Builder) PlaceInt16(x int16)

PlaceInt16 prepends a int16 to the Builder, without checking for space.

func (*Builder) PlaceInt32

func (b *Builder) PlaceInt32(x int32)

PlaceInt32 prepends a int32 to the Builder, without checking for space.

func (*Builder) PlaceInt64

func (b *Builder) PlaceInt64(x int64)

PlaceInt64 prepends a int64 to the Builder, without checking for space.

func (*Builder) PlaceInt8

func (b *Builder) PlaceInt8(x int8)

PlaceInt8 prepends a int8 to the Builder, without checking for space.

func (*Builder) PlaceSOffsetT

func (b *Builder) PlaceSOffsetT(x SOffsetT)

PlaceSOffsetT prepends a SOffsetT to the Builder, without checking for space.

func (*Builder) PlaceUOffsetT

func (b *Builder) PlaceUOffsetT(x UOffsetT)

PlaceUOffsetT prepends a UOffsetT to the Builder, without checking for space.

func (*Builder) PlaceUint16

func (b *Builder) PlaceUint16(x uint16)

PlaceUint16 prepends a uint16 to the Builder, without checking for space.

func (*Builder) PlaceUint32

func (b *Builder) PlaceUint32(x uint32)

PlaceUint32 prepends a uint32 to the Builder, without checking for space.

func (*Builder) PlaceUint64

func (b *Builder) PlaceUint64(x uint64)

PlaceUint64 prepends a uint64 to the Builder, without checking for space.

func (*Builder) PlaceUint8

func (b *Builder) PlaceUint8(x uint8)

PlaceUint8 prepends a uint8 to the Builder, without checking for space.

func (*Builder) PlaceVOffsetT

func (b *Builder) PlaceVOffsetT(x VOffsetT)

PlaceVOffsetT prepends a VOffsetT to the Builder, without checking for space.

func (*Builder) Prep

func (b *Builder) Prep(size, additionalBytes int)

Prep prepares to write an element of `size` after `additional_bytes` have been written, e.g. if you write a string, you need to align such the int length field is aligned to SizeInt32, and the string data follows it directly. If all you need to do is align, `additionalBytes` will be 0.

func (*Builder) PrependBool

func (b *Builder) PrependBool(x bool)

PrependBool prepends a bool to the Builder buffer. Aligns and checks for space.

func (*Builder) PrependBoolSlot

func (b *Builder) PrependBoolSlot(o int, x, d bool)

PrependBoolSlot prepends a bool onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written.

func (*Builder) PrependByte

func (b *Builder) PrependByte(x byte)

PrependByte prepends a byte to the Builder buffer. Aligns and checks for space.

func (*Builder) PrependByteSlot

func (b *Builder) PrependByteSlot(o int, x, d byte)

PrependByteSlot prepends a byte onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written.

func (*Builder) PrependFloat32

func (b *Builder) PrependFloat32(x float32)

PrependFloat32 prepends a float32 to the Builder buffer. Aligns and checks for space.

func (*Builder) PrependFloat32Slot

func (b *Builder) PrependFloat32Slot(o int, x, d float32)

PrependFloat32Slot prepends a float32 onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written.

func (*Builder) PrependFloat64

func (b *Builder) PrependFloat64(x float64)

PrependFloat64 prepends a float64 to the Builder buffer. Aligns and checks for space.

func (*Builder) PrependFloat64Slot

func (b *Builder) PrependFloat64Slot(o int, x, d float64)

PrependFloat64Slot prepends a float64 onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written.

func (*Builder) PrependInt16

func (b *Builder) PrependInt16(x int16)

PrependInt16 prepends a int16 to the Builder buffer. Aligns and checks for space.

func (*Builder) PrependInt16Slot

func (b *Builder) PrependInt16Slot(o int, x, d int16)

PrependInt16Slot prepends a int16 onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written.

func (*Builder) PrependInt32

func (b *Builder) PrependInt32(x int32)

PrependInt32 prepends a int32 to the Builder buffer. Aligns and checks for space.

func (*Builder) PrependInt32Slot

func (b *Builder) PrependInt32Slot(o int, x, d int32)

PrependInt32Slot prepends a int32 onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written.

func (*Builder) PrependInt64

func (b *Builder) PrependInt64(x int64)

PrependInt64 prepends a int64 to the Builder buffer. Aligns and checks for space.

func (*Builder) PrependInt64Slot

func (b *Builder) PrependInt64Slot(o int, x, d int64)

PrependInt64Slot prepends a int64 onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written.

func (*Builder) PrependInt8

func (b *Builder) PrependInt8(x int8)

PrependInt8 prepends a int8 to the Builder buffer. Aligns and checks for space.

func (*Builder) PrependInt8Slot

func (b *Builder) PrependInt8Slot(o int, x, d int8)

PrependInt8Slot prepends a int8 onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written.

func (*Builder) PrependSOffsetT

func (b *Builder) PrependSOffsetT(off SOffsetT)

PrependSOffsetT prepends an SOffsetT, relative to where it will be written.

func (*Builder) PrependStructSlot

func (b *Builder) PrependStructSlot(voffset int, x, d UOffsetT)

PrependStructSlot prepends a struct onto the object at vtable slot `o`. Structs are stored inline, so nothing additional is being added. In generated code, `d` is always 0.

func (*Builder) PrependUOffsetT

func (b *Builder) PrependUOffsetT(off UOffsetT)

PrependUOffsetT prepends an UOffsetT, relative to where it will be written.

func (*Builder) PrependUOffsetTSlot

func (b *Builder) PrependUOffsetTSlot(o int, x, d UOffsetT)

PrependUOffsetTSlot prepends an UOffsetT onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written.

func (*Builder) PrependUint16

func (b *Builder) PrependUint16(x uint16)

PrependUint16 prepends a uint16 to the Builder buffer. Aligns and checks for space.

func (*Builder) PrependUint16Slot

func (b *Builder) PrependUint16Slot(o int, x, d uint16)

PrependUint16Slot prepends a uint16 onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written.

func (*Builder) PrependUint32

func (b *Builder) PrependUint32(x uint32)

PrependUint32 prepends a uint32 to the Builder buffer. Aligns and checks for space.

func (*Builder) PrependUint32Slot

func (b *Builder) PrependUint32Slot(o int, x, d uint32)

PrependUint32Slot prepends a uint32 onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written.

func (*Builder) PrependUint64

func (b *Builder) PrependUint64(x uint64)

PrependUint64 prepends a uint64 to the Builder buffer. Aligns and checks for space.

func (*Builder) PrependUint64Slot

func (b *Builder) PrependUint64Slot(o int, x, d uint64)

PrependUint64Slot prepends a uint64 onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written.

func (*Builder) PrependUint8

func (b *Builder) PrependUint8(x uint8)

PrependUint8 prepends a uint8 to the Builder buffer. Aligns and checks for space.

func (*Builder) PrependUint8Slot

func (b *Builder) PrependUint8Slot(o int, x, d uint8)

PrependUint8Slot prepends a uint8 onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written.

func (*Builder) PrependVOffsetT

func (b *Builder) PrependVOffsetT(x VOffsetT)

PrependVOffsetT prepends a VOffsetT to the Builder buffer. Aligns and checks for space.

func (*Builder) Reset added in v1.2.0

func (b *Builder) Reset()

Reset truncates the underlying Builder buffer, facilitating alloc-free reuse of a Builder. It also resets bookkeeping data.

func (*Builder) Slot

func (b *Builder) Slot(slotnum int)

Slot sets the vtable key `voffset` to the current location in the buffer.

func (*Builder) StartObject

func (b *Builder) StartObject(numfields int)

StartObject initializes bookkeeping for writing a new object.

func (*Builder) StartVector

func (b *Builder) StartVector(elemSize, numElems, alignment int) UOffsetT

StartVector initializes bookkeeping for writing a new vector.

A vector has the following format:

<UOffsetT: number of elements in this vector>
<T: data>+, where T is the type of elements of this vector.

func (*Builder) WriteVtable

func (b *Builder) WriteVtable() (n UOffsetT)

WriteVtable serializes the vtable for the current object, if applicable.

Before writing out the vtable, this checks pre-existing vtables for equality to this one. If an equal vtable is found, point the object to the existing vtable and return.

Because vtable values are sensitive to alignment of object data, not all logically-equal vtables will be deduplicated.

A vtable has the following format:

  <VOffsetT: size of the vtable in bytes, including this value>
  <VOffsetT: size of the object in bytes, including the vtable offset>
  <VOffsetT: offset for a field> * N, where N is the number of fields in
	        the schema for this type. Includes deprecated fields.

Thus, a vtable is made of 2 + N elements, each SizeVOffsetT bytes wide.

An object has the following format:

<SOffsetT: offset to this object's vtable (may be negative)>
<byte: data>+

type FlatBuffer added in v1.5.0

type FlatBuffer interface {
	Table() Table
	Init(buf []byte, i UOffsetT)
}

FlatBuffer is the interface that represents a flatbuffer.

type FlatbuffersCodec added in v1.5.0

type FlatbuffersCodec struct{}

FlatbuffersCodec defines the interface gRPC uses to encode and decode messages. Note that implementations of this interface must be thread safe; a Codec's methods can be called from concurrent goroutines.

func (FlatbuffersCodec) Marshal added in v1.5.0

func (FlatbuffersCodec) Marshal(v interface{}) ([]byte, error)

Marshal returns the wire format of v.

func (FlatbuffersCodec) Name added in v1.12.0

func (FlatbuffersCodec) Name() string

Name returns the name of the Codec implementation. The returned string will be used as part of content type in transmission. The result must be static; the result cannot change between calls.

add Name() for ForceCodec interface

func (FlatbuffersCodec) String added in v1.5.0

func (FlatbuffersCodec) String() string

String old gRPC Codec interface func

func (FlatbuffersCodec) Unmarshal added in v1.5.0

func (FlatbuffersCodec) Unmarshal(data []byte, v interface{}) error

Unmarshal parses the wire format into v.

type KeyCompare

type KeyCompare func(o1, o2 UOffsetT, buf []byte) bool

type SOffsetT

type SOffsetT int32

A SOffsetT stores a signed offset into arbitrary data.

func GetSOffsetT

func GetSOffsetT(buf []byte) SOffsetT

GetSOffsetT decodes a little-endian SOffsetT from a byte slice.

type Struct

type Struct struct {
	Table
}

Struct wraps a byte slice and provides read access to its data.

Structs do not have a vtable.

type Table

type Table struct {
	Bytes []byte
	Pos   UOffsetT // Always < 1<<31.
}

Table wraps a byte slice and provides read access to its data.

The variable `Pos` indicates the root of the FlatBuffers object therein.

func (*Table) ByteVector added in v1.2.0

func (t *Table) ByteVector(off UOffsetT) []byte

ByteVector gets a byte slice from data stored inside the flatbuffer.

func (*Table) GetBool

func (t *Table) GetBool(off UOffsetT) bool

GetBool retrieves a bool at the given offset.

func (*Table) GetBoolSlot

func (t *Table) GetBoolSlot(slot VOffsetT, d bool) bool

GetBoolSlot retrieves the bool that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned.

func (*Table) GetByte

func (t *Table) GetByte(off UOffsetT) byte

GetByte retrieves a byte at the given offset.

func (*Table) GetByteSlot

func (t *Table) GetByteSlot(slot VOffsetT, d byte) byte

GetByteSlot retrieves the byte that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned.

func (*Table) GetFloat32

func (t *Table) GetFloat32(off UOffsetT) float32

GetFloat32 retrieves a float32 at the given offset.

func (*Table) GetFloat32Slot

func (t *Table) GetFloat32Slot(slot VOffsetT, d float32) float32

GetFloat32Slot retrieves the float32 that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned.

func (*Table) GetFloat64

func (t *Table) GetFloat64(off UOffsetT) float64

GetFloat64 retrieves a float64 at the given offset.

func (*Table) GetFloat64Slot

func (t *Table) GetFloat64Slot(slot VOffsetT, d float64) float64

GetFloat64Slot retrieves the float64 that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned.

func (*Table) GetInt16

func (t *Table) GetInt16(off UOffsetT) int16

GetInt16 retrieves a int16 at the given offset.

func (*Table) GetInt16Slot

func (t *Table) GetInt16Slot(slot VOffsetT, d int16) int16

GetInt16Slot retrieves the int16 that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned.

func (*Table) GetInt32

func (t *Table) GetInt32(off UOffsetT) int32

GetInt32 retrieves a int32 at the given offset.

func (*Table) GetInt32Slot

func (t *Table) GetInt32Slot(slot VOffsetT, d int32) int32

GetInt32Slot retrieves the int32 that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned.

func (*Table) GetInt64

func (t *Table) GetInt64(off UOffsetT) int64

GetInt64 retrieves a int64 at the given offset.

func (*Table) GetInt64Slot

func (t *Table) GetInt64Slot(slot VOffsetT, d int64) int64

GetInt64Slot retrieves the int64 that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned.

func (*Table) GetInt8

func (t *Table) GetInt8(off UOffsetT) int8

GetInt8 retrieves a int8 at the given offset.

func (*Table) GetInt8Slot

func (t *Table) GetInt8Slot(slot VOffsetT, d int8) int8

GetInt8Slot retrieves the int8 that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned.

func (*Table) GetSOffsetT

func (t *Table) GetSOffsetT(off UOffsetT) SOffsetT

GetSOffsetT retrieves a SOffsetT at the given offset.

func (*Table) GetUOffsetT

func (t *Table) GetUOffsetT(off UOffsetT) UOffsetT

GetUOffsetT retrieves a UOffsetT at the given offset.

func (*Table) GetUint16

func (t *Table) GetUint16(off UOffsetT) uint16

GetUint16 retrieves a uint16 at the given offset.

func (*Table) GetUint16Slot

func (t *Table) GetUint16Slot(slot VOffsetT, d uint16) uint16

GetUint16Slot retrieves the uint16 that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned.

func (*Table) GetUint32

func (t *Table) GetUint32(off UOffsetT) uint32

GetUint32 retrieves a uint32 at the given offset.

func (*Table) GetUint32Slot

func (t *Table) GetUint32Slot(slot VOffsetT, d uint32) uint32

GetUint32Slot retrieves the uint32 that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned.

func (*Table) GetUint64

func (t *Table) GetUint64(off UOffsetT) uint64

GetUint64 retrieves a uint64 at the given offset.

func (*Table) GetUint64Slot

func (t *Table) GetUint64Slot(slot VOffsetT, d uint64) uint64

GetUint64Slot retrieves the uint64 that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned.

func (*Table) GetUint8

func (t *Table) GetUint8(off UOffsetT) uint8

GetUint8 retrieves a uint8 at the given offset.

func (*Table) GetUint8Slot

func (t *Table) GetUint8Slot(slot VOffsetT, d uint8) uint8

GetUint8Slot retrieves the uint8 that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned.

func (*Table) GetVOffsetT

func (t *Table) GetVOffsetT(off UOffsetT) VOffsetT

GetVOffsetT retrieves a VOffsetT at the given offset.

func (*Table) GetVOffsetTSlot

func (t *Table) GetVOffsetTSlot(slot VOffsetT, d VOffsetT) VOffsetT

GetVOffsetTSlot retrieves the VOffsetT that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned.

func (*Table) Indirect

func (t *Table) Indirect(off UOffsetT) UOffsetT

Indirect retrieves the relative offset stored at `offset`.

func (*Table) MutateBool added in v1.4.0

func (t *Table) MutateBool(off UOffsetT, n bool) bool

MutateBool updates a bool at the given offset.

func (*Table) MutateBoolSlot added in v1.4.0

func (t *Table) MutateBoolSlot(slot VOffsetT, n bool) bool

MutateBoolSlot updates the bool at given vtable location

func (*Table) MutateByte added in v1.4.0

func (t *Table) MutateByte(off UOffsetT, n byte) bool

MutateByte updates a Byte at the given offset.

func (*Table) MutateByteSlot added in v1.4.0

func (t *Table) MutateByteSlot(slot VOffsetT, n byte) bool

MutateByteSlot updates the byte at given vtable location

func (*Table) MutateFloat32 added in v1.4.0

func (t *Table) MutateFloat32(off UOffsetT, n float32) bool

MutateFloat32 updates a Float32 at the given offset.

func (*Table) MutateFloat32Slot added in v1.4.0

func (t *Table) MutateFloat32Slot(slot VOffsetT, n float32) bool

MutateFloat32Slot updates the float32 at given vtable location

func (*Table) MutateFloat64 added in v1.4.0

func (t *Table) MutateFloat64(off UOffsetT, n float64) bool

MutateFloat64 updates a Float64 at the given offset.

func (*Table) MutateFloat64Slot added in v1.4.0

func (t *Table) MutateFloat64Slot(slot VOffsetT, n float64) bool

MutateFloat64Slot updates the float64 at given vtable location

func (*Table) MutateInt16 added in v1.4.0

func (t *Table) MutateInt16(off UOffsetT, n int16) bool

MutateInt16 updates a Int16 at the given offset.

func (*Table) MutateInt16Slot added in v1.4.0

func (t *Table) MutateInt16Slot(slot VOffsetT, n int16) bool

MutateInt16Slot updates the int16 at given vtable location

func (*Table) MutateInt32 added in v1.4.0

func (t *Table) MutateInt32(off UOffsetT, n int32) bool

MutateInt32 updates a Int32 at the given offset.

func (*Table) MutateInt32Slot added in v1.4.0

func (t *Table) MutateInt32Slot(slot VOffsetT, n int32) bool

MutateInt32Slot updates the int32 at given vtable location

func (*Table) MutateInt64 added in v1.4.0

func (t *Table) MutateInt64(off UOffsetT, n int64) bool

MutateInt64 updates a Int64 at the given offset.

func (*Table) MutateInt64Slot added in v1.4.0

func (t *Table) MutateInt64Slot(slot VOffsetT, n int64) bool

MutateInt64Slot updates the int64 at given vtable location

func (*Table) MutateInt8 added in v1.4.0

func (t *Table) MutateInt8(off UOffsetT, n int8) bool

MutateInt8 updates a Int8 at the given offset.

func (*Table) MutateInt8Slot added in v1.4.0

func (t *Table) MutateInt8Slot(slot VOffsetT, n int8) bool

MutateInt8Slot updates the int8 at given vtable location

func (*Table) MutateSOffsetT added in v1.4.0

func (t *Table) MutateSOffsetT(off UOffsetT, n SOffsetT) bool

MutateSOffsetT updates a SOffsetT at the given offset.

func (*Table) MutateUOffsetT added in v1.4.0

func (t *Table) MutateUOffsetT(off UOffsetT, n UOffsetT) bool

MutateUOffsetT updates a UOffsetT at the given offset.

func (*Table) MutateUint16 added in v1.4.0

func (t *Table) MutateUint16(off UOffsetT, n uint16) bool

MutateUint16 updates a Uint16 at the given offset.

func (*Table) MutateUint16Slot added in v1.4.0

func (t *Table) MutateUint16Slot(slot VOffsetT, n uint16) bool

MutateUint16Slot updates the uint16 at given vtable location

func (*Table) MutateUint32 added in v1.4.0

func (t *Table) MutateUint32(off UOffsetT, n uint32) bool

MutateUint32 updates a Uint32 at the given offset.

func (*Table) MutateUint32Slot added in v1.4.0

func (t *Table) MutateUint32Slot(slot VOffsetT, n uint32) bool

MutateUint32Slot updates the uint32 at given vtable location

func (*Table) MutateUint64 added in v1.4.0

func (t *Table) MutateUint64(off UOffsetT, n uint64) bool

MutateUint64 updates a Uint64 at the given offset.

func (*Table) MutateUint64Slot added in v1.4.0

func (t *Table) MutateUint64Slot(slot VOffsetT, n uint64) bool

MutateUint64Slot updates the uint64 at given vtable location

func (*Table) MutateUint8 added in v1.4.0

func (t *Table) MutateUint8(off UOffsetT, n uint8) bool

MutateUint8 updates a Uint8 at the given offset.

func (*Table) MutateUint8Slot added in v1.4.0

func (t *Table) MutateUint8Slot(slot VOffsetT, n uint8) bool

MutateUint8Slot updates the uint8 at given vtable location

func (*Table) MutateVOffsetT added in v1.4.0

func (t *Table) MutateVOffsetT(off UOffsetT, n VOffsetT) bool

MutateVOffsetT updates a VOffsetT at the given offset.

func (*Table) Offset

func (t *Table) Offset(vtableOffset VOffsetT) VOffsetT

Offset provides access into the Table's vtable.

Fields which are deprecated are ignored by checking against the vtable's length.

func (*Table) String

func (t *Table) String(off UOffsetT) string

String gets a string from data stored inside the flatbuffer.

func (*Table) Union

func (t *Table) Union(t2 *Table, off UOffsetT)

Union initializes any Table-derived type to point to the union at the given offset.

func (*Table) Vector

func (t *Table) Vector(off UOffsetT) UOffsetT

Vector retrieves the start of data of the vector whose offset is stored at "off" in this object.

func (*Table) VectorLen

func (t *Table) VectorLen(off UOffsetT) int

VectorLen retrieves the length of the vector whose offset is stored at "off" in this object.

type UOffsetT

type UOffsetT uint32

A UOffsetT stores an unsigned offset into vector data.

func GetIndirectOffset

func GetIndirectOffset(buf []byte, offset UOffsetT) UOffsetT

GetIndirectOffset retrives the relative offset in the provided buffer stored at `offset`.

func GetUOffsetT

func GetUOffsetT(buf []byte) UOffsetT

GetUOffsetT decodes a little-endian UOffsetT from a byte slice.

type VOffsetT

type VOffsetT uint16

A VOffsetT stores an unsigned offset in a vtable.

func GetVOffsetT

func GetVOffsetT(buf []byte) VOffsetT

GetVOffsetT decodes a little-endian VOffsetT from a byte slice.

Jump to

Keyboard shortcuts

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