flatbuffers

package
v0.0.0-...-ed9a05a Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2020 License: Apache-2.0 Imports: 11 Imported by: 15

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 DefaultMaxBatch = (1 << 8) - 1

default max batch size for batched consumers

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.

View Source
var EnumNamesFieldType = map[FieldType]string{
	FieldTypeNone:        "None",
	FieldTypeUType:       "UType",
	FieldTypeBool:        "Bool",
	FieldTypeInt8:        "Int8",
	FieldTypeUint8:       "Uint8",
	FieldTypeByte:        "Byte",
	FieldTypeInt16:       "Int16",
	FieldTypeUint16:      "Uint16",
	FieldTypeInt32:       "Int32",
	FieldTypeUint32:      "Uint32",
	FieldTypeInt64:       "Int64",
	FieldTypeUint64:      "Uint64",
	FieldTypeFloat32:     "Float32",
	FieldTypeFloat64:     "Float64",
	FieldTypeString:      "String",
	FieldTypeByteSlice:   "ByteSlice",
	FieldTypeInt8Slice:   "Int8Slice",
	FieldTypeVectorPoint: "VectorPoint",
	FieldTypeScalar:      "Scalar",
	FieldTypeEnum:        "Enum",
	FieldTypeStruct:      "Struct",
	FieldTypeTable:       "Table",
	FieldTypeUnion:       "Union",
	FieldTypeArray:       "Array",
	FieldTypeFlexTable:   "FlexTable",
	FieldTypeCustomized:  "Customized",
}
View Source
var EnumValuesFieldType = map[string]FieldType{
	"None":        FieldTypeNone,
	"UType":       FieldTypeUType,
	"Bool":        FieldTypeBool,
	"Int8":        FieldTypeInt8,
	"Uint8":       FieldTypeUint8,
	"Byte":        FieldTypeByte,
	"Int16":       FieldTypeInt16,
	"Uint16":      FieldTypeUint16,
	"Int32":       FieldTypeInt32,
	"Uint32":      FieldTypeUint32,
	"Int64":       FieldTypeInt64,
	"Uint64":      FieldTypeUint64,
	"Float32":     FieldTypeFloat32,
	"Float64":     FieldTypeFloat64,
	"String":      FieldTypeString,
	"ByteSlice":   FieldTypeByteSlice,
	"Int8Slice":   FieldTypeInt8Slice,
	"VectorPoint": FieldTypeVectorPoint,
	"Scalar":      FieldTypeScalar,
	"Enum":        FieldTypeEnum,
	"Struct":      FieldTypeStruct,
	"Table":       FieldTypeTable,
	"Union":       FieldTypeUnion,
	"Array":       FieldTypeArray,
	"FlexTable":   FieldTypeFlexTable,
	"Customized":  FieldTypeCustomized,
}

Functions

func B2S

func B2S(b []byte) string

B2S converts byte slice to a string without memory allocation. See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .

Note it may break if string and/or slice B will change in the future go versions.

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

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 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 Prepad

func Prepad(size, additionalBytes int) (int, int)

Pad prepad

func S2B

func S2B(s string) (b []byte)

S2B converts string to a byte slice without memory allocation.

Note it may break if string and/or slice B will change in the future go versions.

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

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

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

func (*Builder) CreateByteVector

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

CreateByteVector writes a ubyte vector

func (*Builder) CreateSharedString

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) 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) FinishWithFileIdentifier

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

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

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) StringsVector

func (b *Builder) StringsVector(str ...string) UOffsetT

StringsVector a shortcut to pack []string

func (*Builder) VectorArray

func (b *Builder) VectorArray(off ...UOffsetT) UOffsetT

VectorArray shortcut for vector array ( UOffset array ) like strings / tables / unions

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 FieldDef

type FieldDef struct {
	// contains filtered or unexported fields
}

type FieldRegister

type FieldRegister struct {
	// contains filtered or unexported fields
}

Stack single publish, single consume

func (*FieldRegister) Close

func (r *FieldRegister) Close()

Close close

func (*FieldRegister) Done

func (r *FieldRegister) Done() bool

Done done

func (*FieldRegister) Grow

func (r *FieldRegister) Grow()

func (*FieldRegister) Init

func (r *FieldRegister) Init(n uint32)

func (*FieldRegister) Len

func (r *FieldRegister) Len() int

func (*FieldRegister) Pop

func (r *FieldRegister) Pop() (v VField, b bool)

Get check item iextis or net

func (*FieldRegister) Push

func (r *FieldRegister) Push(v VField)

Put put item into queue

func (*FieldRegister) PushAt

func (r *FieldRegister) PushAt(off int, v VField)

Put put item into queue

func (*FieldRegister) Size

func (r *FieldRegister) Size() int

type FieldType

type FieldType int8
const (
	FieldTypeNone        FieldType = 0
	FieldTypeUType       FieldType = 1
	FieldTypeBool        FieldType = 2
	FieldTypeInt8        FieldType = 3
	FieldTypeUint8       FieldType = 4
	FieldTypeByte        FieldType = 5
	FieldTypeInt16       FieldType = 6
	FieldTypeUint16      FieldType = 7
	FieldTypeInt32       FieldType = 8
	FieldTypeUint32      FieldType = 9
	FieldTypeInt64       FieldType = 10
	FieldTypeUint64      FieldType = 11
	FieldTypeFloat32     FieldType = 12
	FieldTypeFloat64     FieldType = 13
	FieldTypeString      FieldType = 14
	FieldTypeByteSlice   FieldType = 15
	FieldTypeInt8Slice   FieldType = 16
	FieldTypeVectorPoint FieldType = 17
	FieldTypeScalar      FieldType = 18
	FieldTypeEnum        FieldType = 19
	FieldTypeStruct      FieldType = 20
	FieldTypeTable       FieldType = 21
	FieldTypeUnion       FieldType = 22
	FieldTypeArray       FieldType = 23
	FieldTypeFlexTable   FieldType = 24
	FieldTypeCustomized  FieldType = 25
)

func (FieldType) String

func (v FieldType) String() string

type FlatBuffer

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

FlatBuffer is the interface that represents a flatbuffer.

type FlatBuilder

type FlatBuilder struct {
	VirtualTable
	// contains filtered or unexported fields
}

FlatBuilder flatbuffers builder

func NewFlatBuilder

func NewFlatBuilder() *FlatBuilder

NewFlatBuilder new flatbuffers builder

type FlatbuffersCodec

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

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

Marshal returns the wire format of v.

func (FlatbuffersCodec) Name

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

func (FlatbuffersCodec) String() string

String old gRPC Codec interface func

func (FlatbuffersCodec) Unmarshal

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

Unmarshal parses the wire format into v.

type Header struct {
	// contains filtered or unexported fields
}

Header root B

func (*Header) SetIdentifier

func (h *Header) SetIdentifier(name []byte)

type Queue

type Queue interface {
	Pop() (VField, bool)
	Size() int
	Len() int
	NumsElement() int
	Push(VField)
	Close()
}

Generic queue interfacelist mathing all implementations

func NewStack

func NewStack(n uint32) Queue

type Register

type Register interface {
	Pop() (VField, bool)
	Size() int
	Len() int
	Push(VField)
	Close()
}

Generic queue interfacelist mathing all implementations

func NewFieldRegister

func NewFieldRegister(n uint32) Register

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 Scalar

type Scalar struct {
	FieldName string // field name for json object, come from flatc compiler

	VOffset VOffsetT // for scalar vec only, vec's scalar field VOffset be pre-defined in flatc compiler
	// contains filtered or unexported fields
}

Scalar vec for scalar in flatc

func NewScalar

func NewScalar() *Scalar

NewScalar new

func (*Scalar) Bool

func (b *Scalar) Bool(x bool) VField

Bool encoded

func (*Scalar) Byte

func (b *Scalar) Byte(x byte) VField

func (*Scalar) ByteSize

func (b *Scalar) ByteSize() int

func (*Scalar) FinishedBytes

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

FinishedBytes return []byte

func (*Scalar) Float32

func (b *Scalar) Float32(x float32) VField

Float32 encoded

func (*Scalar) Float64

func (b *Scalar) Float64(x float64) VField

Float64 encoded

func (*Scalar) Int16

func (b *Scalar) Int16(x int16) VField

Int16 encoded

func (*Scalar) Int32

func (b *Scalar) Int32(x int32) VField

Int32 encoded

func (*Scalar) Int64

func (b *Scalar) Int64(x int64) VField

Int64 encoded

func (*Scalar) Int8

func (b *Scalar) Int8(x int8) VField

Int8 encoded

func (*Scalar) IsFinished

func (b *Scalar) IsFinished() bool

Finished is finish

func (*Scalar) IsVector

func (b *Scalar) IsVector() bool

IsVector is vector or not

func (*Scalar) ObjectSize

func (b *Scalar) ObjectSize() int

ObjectSize return scalar encoded binary size

func (*Scalar) Press

func (b *Scalar) Press() error

Serialize process

func (*Scalar) Release

func (b *Scalar) Release() bool

Pack pack

func (*Scalar) Type

func (b *Scalar) Type() FieldType

Type return field type

func (*Scalar) TypeName

func (b *Scalar) TypeName() string

TypeName return type name

func (*Scalar) Ubyte

func (b *Scalar) Ubyte(x int8) VField

func (*Scalar) Uint16

func (b *Scalar) Uint16(x uint16) VField

Uint16 encoded

func (*Scalar) Uint32

func (b *Scalar) Uint32(x uint32) VField

Uint32 encoded

func (*Scalar) Uint64

func (b *Scalar) Uint64(x uint64) VField

Uint64 encoded

func (*Scalar) Uint8

func (b *Scalar) Uint8(x uint8) VField

Uint8 encoded

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

Stack single publish, single consume

func (*Stack) Close

func (r *Stack) Close()

Close close

func (*Stack) Done

func (r *Stack) Done() bool

Done done

func (*Stack) Grow

func (r *Stack) Grow()

func (*Stack) Init

func (r *Stack) Init(n uint32)

func (*Stack) Len

func (r *Stack) Len() int

func (*Stack) NumsElement

func (r *Stack) NumsElement() int

func (*Stack) Pop

func (r *Stack) Pop() (v VField, b bool)

Get check item iextis or net

func (*Stack) Push

func (r *Stack) Push(v VField)

Put put item into queue

func (*Stack) Size

func (r *Stack) Size() int

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 StructBuffers

type StructBuffers struct {
	// contains filtered or unexported fields
}

StructBuffers scalar vec

func NewFixedStruct

func NewFixedStruct(bytesize int) *StructBuffers

func NewStruct

func NewStruct() *StructBuffers

NewScalarStruct new scalar vec

func (*StructBuffers) Bool

func (b *StructBuffers) Bool(x bool, n UOffsetT) *StructBuffers

Bool insert a field into vec

func (*StructBuffers) Byte

func (b *StructBuffers) Byte(x byte, n UOffsetT) *StructBuffers

Int8 insert a field into vec

func (*StructBuffers) ByteSize

func (b *StructBuffers) ByteSize() int

B return []byte

func (*StructBuffers) FinishedBytes

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

FinishedBytes return []byte

func (*StructBuffers) Float32

func (b *StructBuffers) Float32(x float32, n UOffsetT) *StructBuffers

Float32 insert a field into vec

func (*StructBuffers) Float64

func (b *StructBuffers) Float64(x float64, n UOffsetT) *StructBuffers

Float64 insert a field into vec

func (*StructBuffers) Int16

func (b *StructBuffers) Int16(x int16, n UOffsetT) *StructBuffers

Int16 insert a field into vec

func (*StructBuffers) Int32

func (b *StructBuffers) Int32(x int32, n UOffsetT) *StructBuffers

Int32 insert a field into vec

func (*StructBuffers) Int64

func (b *StructBuffers) Int64(x int64, n UOffsetT) *StructBuffers

Int64 insert a field into vec

func (*StructBuffers) Int8

func (b *StructBuffers) Int8(x int8, n UOffsetT) *StructBuffers

Int8 insert a field into vec

func (*StructBuffers) IsFinished

func (b *StructBuffers) IsFinished() bool

Finished return serialize result

func (*StructBuffers) IsVector

func (b *StructBuffers) IsVector() bool

IsVector is vector or not

func (*StructBuffers) ObjectSize

func (b *StructBuffers) ObjectSize() int

B return []byte

func (*StructBuffers) Pad

func (b *StructBuffers) Pad(n int, u UOffsetT) *StructBuffers

Pad filled the pad via "0" byte

func (*StructBuffers) Prep

func (b *StructBuffers) Prep(minalign, bytesize int) *StructBuffers

Init initial scalar vec

func (*StructBuffers) Press

func (b *StructBuffers) Press() error

func (*StructBuffers) Release

func (b *StructBuffers) Release() bool

Pack pack

func (*StructBuffers) SetName

func (b *StructBuffers) SetName(name string) *StructBuffers

SetName

func (*StructBuffers) Size

func (b *StructBuffers) Size() int

Size return byte size

func (*StructBuffers) StructEnd

func (b *StructBuffers) StructEnd() *StructBuffers

StructEnd finish scalar vec

func (*StructBuffers) StructStart

func (b *StructBuffers) StructStart(minalign, bytesize, slot int) *StructBuffers

Init initial scalar vec

func (*StructBuffers) Type

func (b *StructBuffers) Type() FieldType

Type return field type

func (*StructBuffers) TypeName

func (b *StructBuffers) TypeName() string

TypeName name of vec

func (*StructBuffers) Uint16

func (b *StructBuffers) Uint16(x uint16, n UOffsetT) *StructBuffers

Uint16 insert a field into vec

func (*StructBuffers) Uint32

func (b *StructBuffers) Uint32(x uint32, n UOffsetT) *StructBuffers

Uint32 insert a field into vec

func (*StructBuffers) Uint64

func (b *StructBuffers) Uint64(x uint64, n UOffsetT) *StructBuffers

Uint64 insert a field into vec

func (*StructBuffers) Uint8

func (b *StructBuffers) Uint8(x uint8, n UOffsetT) *StructBuffers

Uint8 insert a field into vec

type StructDef

type StructDef struct {
	// contains filtered or unexported fields
}

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

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

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

MutateBool updates a bool at the given offset.

func (*Table) MutateBoolSlot

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

MutateBoolSlot updates the bool at given vtable location

func (*Table) MutateByte

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

MutateByte updates a Byte at the given offset.

func (*Table) MutateByteSlot

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

MutateByteSlot updates the byte at given vtable location

func (*Table) MutateFloat32

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

MutateFloat32 updates a Float32 at the given offset.

func (*Table) MutateFloat32Slot

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

MutateFloat32Slot updates the float32 at given vtable location

func (*Table) MutateFloat64

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

MutateFloat64 updates a Float64 at the given offset.

func (*Table) MutateFloat64Slot

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

MutateFloat64Slot updates the float64 at given vtable location

func (*Table) MutateInt16

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

MutateInt16 updates a Int16 at the given offset.

func (*Table) MutateInt16Slot

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

MutateInt16Slot updates the int16 at given vtable location

func (*Table) MutateInt32

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

MutateInt32 updates a Int32 at the given offset.

func (*Table) MutateInt32Slot

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

MutateInt32Slot updates the int32 at given vtable location

func (*Table) MutateInt64

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

MutateInt64 updates a Int64 at the given offset.

func (*Table) MutateInt64Slot

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

MutateInt64Slot updates the int64 at given vtable location

func (*Table) MutateInt8

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

MutateInt8 updates a Int8 at the given offset.

func (*Table) MutateInt8Slot

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

MutateInt8Slot updates the int8 at given vtable location

func (*Table) MutateSOffsetT

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

MutateSOffsetT updates a SOffsetT at the given offset.

func (*Table) MutateUOffsetT

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

MutateUOffsetT updates a UOffsetT at the given offset.

func (*Table) MutateUint16

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

MutateUint16 updates a Uint16 at the given offset.

func (*Table) MutateUint16Slot

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

MutateUint16Slot updates the uint16 at given vtable location

func (*Table) MutateUint32

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

MutateUint32 updates a Uint32 at the given offset.

func (*Table) MutateUint32Slot

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

MutateUint32Slot updates the uint32 at given vtable location

func (*Table) MutateUint64

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

MutateUint64 updates a Uint64 at the given offset.

func (*Table) MutateUint64Slot

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

MutateUint64Slot updates the uint64 at given vtable location

func (*Table) MutateUint8

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

MutateUint8 updates a Uint8 at the given offset.

func (*Table) MutateUint8Slot

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

MutateUint8Slot updates the uint8 at given vtable location

func (*Table) MutateVOffsetT

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) StringsVector

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

ByteInUnion gets a byte slice from data stored inside the union.

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 TableHeader

type TableHeader interface {
	TableSize() int
	FinishByte() []byte
}

TableHeader define table header

type TypeCode

type TypeCode struct {
	Id             uint16
	Offset         uint16
	Name           string
	BaseType       FieldType
	FieldType      FieldType
	DefaultInteger int64
	DefaultReal    float64
	Element        FieldType
	Index          int32
	FixedLength    uint16
	IsVector       bool // set true if vector field
	IsDeprecated   bool // set true if deprecated field
	SequenceRef    TypeTable
}

TypeCode define type code for scalar / enum in IDL

type TypeFunction

type TypeFunction func() TypeTable

TypeFunction a func return TypeTable

type TypeTable

type TypeTable struct {
	SequenceType FieldType
	IsRootType   bool // set true if set root_type
	Minalign     int32
	Bytesize     int32
	NumsElement  int // how many field inside
	FixedLength  int // default is 0,  set if fixed size like struct
	Name         []byte
	RootType     []byte // root_type name
	Identifier   []byte // set if root table with file_identifier

	Fields []TypeCode
}

TypeTable define type table, for enum / struct / union / table in IDL SequenceType : table / struct / union / enum , only 4 type in SequenceType

type UOffsetT

type UOffsetT uint32

A UOffsetT stores an unsigned offset into vector data.

func GetUOffsetT

func GetUOffsetT(buf []byte) UOffsetT

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

type Union

type Union struct {
	Type  byte
	Table *Table
}

Union

type VField

type VField interface {
	IsVector() bool   // is vector or not
	IsFinished() bool // check is serialize operation done or not
	FinishedBytes() []byte
	Release() bool
	ByteSize() int
	ObjectSize() int
	Type() FieldType //  scalar / union / vector
	Press() error    // worker for goroutine
}

VField field of VTable

func VectorString

func VectorString(s string) VField

VectorString create string vector

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.

type VTable

type VTable struct {
	// contains filtered or unexported fields
}

VTable virtual table

func NewVTable

func NewVTable() *VTable

func (*VTable) ByteSize

func (v *VTable) ByteSize() int

ByteSize return

func (*VTable) Hash

func (v *VTable) Hash() uint64

Hash return vtable hash

func (*VTable) Head

func (v *VTable) Head() uint16

Head return head

func (*VTable) Init

func (v *VTable) Init(n, fixed int) *VTable

func (*VTable) Payload

func (v *VTable) Payload() []byte

Payload return

func (*VTable) SetObjectSize

func (v *VTable) SetObjectSize(n int) *VTable

SetObjectSize set object size

func (*VTable) SetVOffset

func (v *VTable) SetVOffset(id int, off uint16) *VTable

type Vector

type Vector struct {
	FieldName string // field name for json object, come from flatc compiler

	VOffset VOffsetT // for scalar vec only, vec's scalar field VOffset be pre-defined in flatc compiler
	// contains filtered or unexported fields
}

IsVector vector vec

func NewVector

func NewVector() *Vector

NewVector new vector

func (*Vector) ByteSize

func (b *Vector) ByteSize() int

func (*Vector) ByteSlice

func (b *Vector) ByteSlice(off VOffsetT, s []byte) VField

ByteSlice add a byte slice vector

func (*Vector) EndVector

func (b *Vector) EndVector(vectorNumElems int) VField

EndVector writes data necessary to finish vector construction.

func (*Vector) FinishedBytes

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

FinishedBytes finish serialize and return []byte

func (*Vector) Int8Slice

func (b *Vector) Int8Slice(off VOffsetT, s []int8) VField

Int8Slice add a int8 slice vector

func (*Vector) IsFinished

func (b *Vector) IsFinished() bool

Finished bool

func (*Vector) IsVector

func (b *Vector) IsVector() bool

IsVector bool

func (*Vector) ObjectSize

func (b *Vector) ObjectSize() int

func (*Vector) Press

func (b *Vector) Press() error

Serialize work

func (*Vector) Release

func (b *Vector) Release() bool

func (*Vector) ScalarArray

func (b *Vector) ScalarArray(off VOffsetT, s ...VField) VField

ScalarArray add a string vector

func (*Vector) SharedString

func (b *Vector) SharedString(off VOffsetT, s string) VField

SharedString add a shared string vector

func (*Vector) String

func (b *Vector) String(off VOffsetT, s string) VField

String add a string vector

func (*Vector) StructArray

func (b *Vector) StructArray(off VOffsetT, s ...VField) VField

StructArray add a string vector

func (*Vector) Type

func (b *Vector) Type() FieldType

Type field type

func (*Vector) TypeName

func (b *Vector) TypeName() string

TypeName type name

func (*Vector) VectcorArray

func (b *Vector) VectcorArray(off VOffsetT, s ...VField) VField

VectcorArray add a string vector

type VirtualTable

type VirtualTable struct {
	// contains filtered or unexported fields
}

VirtualTable virtual table

func NewVirtualTable

func NewVirtualTable() *VirtualTable

NewVirtualTable initial virtual table

func (*VirtualTable) AllSet

func (b *VirtualTable) AllSet() bool

AllSet check all field been registered or not

func (*VirtualTable) Array

func (b *VirtualTable) Array(slot int, vf VOffsetT, in VField) *VirtualTable

Array register array

func (*VirtualTable) ByteSize

func (b *VirtualTable) ByteSize() int

ByteSize size of serialized binary slice

func (*VirtualTable) EndTable

func (b *VirtualTable) EndTable() *VirtualTable

EndTable end table

func (*VirtualTable) Finish

func (b *VirtualTable) Finish() VField

Finish do serialize job

func (*VirtualTable) FinishedBytes

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

FinishedBytes return []byte

func (*VirtualTable) FlexTable

func (b *VirtualTable) FlexTable(slot int, vf VOffsetT, in VField) *VirtualTable

FlexTable register flex table

func (*VirtualTable) Head

func (b *VirtualTable) Head() int

Head return head offset

func (*VirtualTable) Init

func (b *VirtualTable) Init(minalign, bytesize, slot int) *VirtualTable

func (*VirtualTable) IsFinished

func (b *VirtualTable) IsFinished() bool

IsFinished check serialize job done or not

func (*VirtualTable) IsVector

func (b *VirtualTable) IsVector() bool

IsVector check this VField is vector or not

func (*VirtualTable) ObjectSize

func (b *VirtualTable) ObjectSize() int

ObjectSize object size in VTable

func (*VirtualTable) Press

func (b *VirtualTable) Press() error

Press do the serialize job

func (*VirtualTable) Release

func (b *VirtualTable) Release() bool

Release set cache back to pool

func (*VirtualTable) SOffset

func (b *VirtualTable) SOffset() int

SOffset return SOffset

func (*VirtualTable) Scalar

func (b *VirtualTable) Scalar(slot int, vf VOffsetT, in, df VField) *VirtualTable

Scalar register scalar

func (*VirtualTable) StartTable

func (b *VirtualTable) StartTable(i int) *VirtualTable

StartTable start table

func (*VirtualTable) String

func (b *VirtualTable) String(slot int, vf VOffsetT, in, df VField) *VirtualTable

String register string

func (*VirtualTable) Struct

func (b *VirtualTable) Struct(slot int, vf VOffsetT, in VField) *VirtualTable

Struct register string

func (*VirtualTable) Table

func (b *VirtualTable) Table(slot int, vf VOffsetT, in VField) *VirtualTable

Table register table

func (*VirtualTable) TableSize

func (b *VirtualTable) TableSize() int

TableSize table size

func (*VirtualTable) Type

func (b *VirtualTable) Type() FieldType

Type virtual field type

func (*VirtualTable) Union

func (b *VirtualTable) Union(slot int, vf VOffsetT, in VField) *VirtualTable

Union register table

func (*VirtualTable) UnionType

func (b *VirtualTable) UnionType(slot int, vf VOffsetT, in, df VField) *VirtualTable

UnionType register table // scalar.byte

func (*VirtualTable) Vector

func (b *VirtualTable) Vector(slot int, vf VOffsetT, in VField) *VirtualTable

Vector register vector

Directories

Path Synopsis
code copy from github.com/libp2p/go-buffer-pool, copyright belong to The Go Authors and Steven Allen.
code copy from github.com/libp2p/go-buffer-pool, copyright belong to The Go Authors and Steven Allen.
extras

Jump to

Keyboard shortcuts

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