base

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// DEFAULT_BUF_CAP .. cap size of Base's buffef([]byte)
	DEFAULT_BUF_CAP = 512
	// DEFAULT_NODE_BUF_CAP ... cap size of Base's buffer via CreateNode
	DEFAULT_NODE_BUF_CAP = 64
)
View Source
const (
	BASE_IMPL = iota
	BASE_NO_LAYER
	BASE_DOUBLE_LAYER
	BASE_DIRECT_READER
)
View Source
const (
	FLT_NONE = 1 << iota
	FLT_NORMAL
	FLT_IS
	FLT_IO
)
View Source
const (
	SizeOfbool    = 1
	SizeOfint8    = 1
	SizeOfint16   = 2
	SizeOfuint16  = 2
	SizeOfint32   = 4
	SizeOfuint32  = 4
	SizeOfint64   = 8
	SizeOfuint64  = 8
	SizeOffloat32 = 4
	SizeOffloat64 = 8
	SizeOfuint8   = 1
	SizeOfbyte    = 1
)
View Source
const (
	TypeBool = iota
	TypeByte
	TypeInt8
	TypeInt16
	TypeInt32
	TypeInt64
	TypeUint8
	TypeUint16
	TypeUint32
	TypeUint64
	TypeFloat32
	TypeFloat64
)
View Source
const (
	FieldTypeNone = 1 << iota
	FieldTypeStruct
	FieldTypeTable
	FieldTypeUnion
	FieldTypeSlice
	FieldTypeBasic1
	FieldTypeBasic2
	FieldTypeBasic4
	FieldTypeBasic8
)

Variables

View Source
var (
	ERR_MUST_POINTER       error = log.ERR_MUST_POINTER
	ERR_INVALID_TYPE       error = log.ERR_INVALID_TYPE
	ERR_NOT_FOUND          error = log.ERR_NOT_FOUND
	ERR_READ_BUFFER        error = log.ERR_READ_BUFFER
	ERR_MORE_BUFFER        error = log.ERR_MORE_BUFFER
	ERR_NO_SUPPORT         error = log.ERR_NO_SUPPORT
	ERR_INVALID_INDEX      error = log.ERR_INVALID_INDEX
	ERR_NO_INCLUDE_ROOT    error = log.ERR_NO_INCLUDE_ROOT
	ERR_INVLIAD_WRITE_SIZE error = log.ERR_INVLIAD_WRITE_SIZE
	ERR_OVERWARP_DIFF      error = errors.New("old diff is overwarap current dfff")
)
View Source
var All_IdxToName map[string](map[int]string) = map[string](map[int]string){}
View Source
var All_IdxToType map[string](map[int]int) = map[string](map[int]int){}
View Source
var All_IdxToTypeGroup map[string](map[int]int) = map[string](map[int]int){}
View Source
var All_NameToIdx map[string](map[string]int) = map[string](map[string]int){}
View Source
var (
	AlreadReadError = errors.New("read already")
)
View Source
var (
	// tag for Marshal/Unmarshal
	FBS_TAG_NAME string = "fbs"
)
View Source
var IdxNames []string = []string{}
View Source
var IsStructName map[string]bool = map[string]bool{}
View Source
var Name2Idx map[string]int = map[string]int{}
View Source
var NameToType map[string]int = map[string]int{
	"bool":    TypeBool,
	"byte":    TypeByte,
	"int8":    TypeInt8,
	"int16":   TypeInt16,
	"int32":   TypeInt32,
	"int64":   TypeInt64,
	"unt8":    TypeUint8,
	"uint16":  TypeUint16,
	"uint32":  TypeUint32,
	"uint64":  TypeUint64,
	"float32": TypeFloat32,
	"float64": TypeFloat64,
	"Bool":    TypeBool,
	"Byte":    TypeByte,
	"Int8":    TypeInt8,
	"Int16":   TypeInt16,
	"Int32":   TypeInt32,
	"Int64":   TypeInt64,
	"Unt8":    TypeUint8,
	"Uint16":  TypeUint16,
	"Uint32":  TypeUint32,
	"Uint64":  TypeUint64,
	"Float32": TypeFloat32,
	"Float64": TypeFloat64,
}
View Source
var RootName string = ""

RootName undocumented

View Source
var TypeToSize map[int]int = map[int]int{
	TypeBool:    1,
	TypeByte:    1,
	TypeInt8:    1,
	TypeInt16:   2,
	TypeInt32:   4,
	TypeInt64:   8,
	TypeUint8:   1,
	TypeUint16:  2,
	TypeUint32:  4,
	TypeUint64:  8,
	TypeFloat32: 4,
	TypeFloat64: 8,
}
View Source
var UnionAlias map[string][]string = map[string][]string{}

Functions

func AddName

func AddName(s string)

func ApplyRequestNameFields

func ApplyRequestNameFields()

func AtoiNoErr

func AtoiNoErr(i int, e error) int

func FF added in v0.4.1

func FF(s string, v ...interface{})

func FbsString

func FbsString(node *Node) []byte

FbsString ... return []bytes for string data

func GetTypeGroup

func GetTypeGroup(s string) (result int)

func HasNameType

func HasNameType(s string) bool

func IsFieldBasicType

func IsFieldBasicType(i int) bool

func IsFieldBytes

func IsFieldBytes(i int) bool

func IsFieldSlice

func IsFieldSlice(i int) bool

func IsFieldStruct

func IsFieldStruct(i int) bool

func IsFieldTable

func IsFieldTable(i int) bool

func IsFieldUnion

func IsFieldUnion(i int) bool

func IsMatchBit

func IsMatchBit(i, j int) bool

IsMatchBit ... is used bit field . mainly Field Type

func IsSameField

func IsSameField(i, j uint32) bool

func IsSameTable

func IsSameTable(i, j uint32) bool

func IsUnionName

func IsUnionName(s string) bool

func L2isEnable added in v0.2.3

func L2isEnable(param Log2Option) bool

func Log

func Log(l LogLevel, fn LogFn)

if no output , not eval args

Log(LOG_DEBUG, func() LogArgs { return F("test %d \n", 1) })

func Log2 added in v0.2.3

func Log2(opts ...Log2Option) (result interface{})

Log2 ... logger with lazy evaluation and filter mode

func MaxInt added in v0.2.0

func MaxInt(vals ...int) (r int)

MaxInt ... return maxinum value from values

func MinInt added in v0.2.0

func MinInt(vals ...int) (r int)

MinInt ... return minimum value from values

func NameToTypeEnum

func NameToTypeEnum(s string) int

func NodeFieldSynmbol

func NodeFieldSynmbol(node, field string) (uint32, error)

func RequestSettingNameFields

func RequestSettingNameFields(nName, fName, fType string, fNum int) bool

func SetAlias

func SetAlias(union, alias string) bool

func SetIdxToName

func SetIdxToName(name string, v map[int]string)

func SetIdxToType

func SetIdxToType(name string, v map[int]int)

func SetL2Current added in v0.2.3

func SetL2Current(level log.LogLevel, filter byte)

func SetLogLevel

func SetLogLevel(l LogLevel)

func SetNameIsStrunct

func SetNameIsStrunct(name string, enable bool) bool

func SetNameToIdx

func SetNameToIdx(name string, v map[string]int)

func SetRootName

func SetRootName(s string)

SetRootName undocumented

func SetdxToTypeGroup

func SetdxToTypeGroup(name string, v map[int]int)

func SumInts added in v0.2.3

func SumInts(ints []int) int

SumInts ... sum of []int

func Symbol

func Symbol(s string) int

func SymbolToNames

func SymbolToNames(idx uint32) (node, field string, e error)

func SymbolToString

func SymbolToString(i int) string

func ToBool

func ToBool(s string) bool

func VlensTotals added in v0.2.3

func VlensTotals(lists []*List) ([]int, []int)

Types

type BaseImpl added in v0.1.2

type BaseImpl struct {
	RDiffs []Diff
	Diffs  []Diff
	// contains filtered or unexported fields
}

BaseImpl ... Base Object of byte buffer for flatbuffers read from r and store bytes. Diffs has jounals for writing

func NewBaseImpl added in v0.1.4

func NewBaseImpl(buf []byte) *BaseImpl

NewBaseImpl ... initialize BaseImpl struct via buffer(buf)

func NewBaseImplByIO added in v0.1.4

func NewBaseImplByIO(rio io.Reader, cap int, o *BaseImpl) *BaseImpl

NewBaseImplByIO ... return new BaseImpl instance with io.Reader

func (*BaseImpl) AddDirty added in v0.1.2

func (b *BaseImpl) AddDirty(d Dirty)

AddDirty ... add dirty of ValueInfo.

func (*BaseImpl) AddRDiff added in v0.4.1

func (b *BaseImpl) AddRDiff(diff Diff) error

func (*BaseImpl) BufInfo added in v0.1.2

func (b *BaseImpl) BufInfo() (infos BufInfo)

BufInfo ... return infos(buffer detail information)

func (*BaseImpl) Bytes added in v0.2.0

func (b *BaseImpl) Bytes() []byte

Bytes undocumented

func (*BaseImpl) C added in v0.1.2

func (b *BaseImpl) C(off, size int, src []byte) error

C ... copy buffer Deprecated: should use Copy

func (*BaseImpl) ClearValueInfoOnDirty added in v0.1.2

func (b *BaseImpl) ClearValueInfoOnDirty(node *NodeList)

ClearValueInfoOnDirty ... notify to be changed ValueInfo.

func (*BaseImpl) Copy added in v0.1.2

func (b *BaseImpl) Copy(src IO, srcOff, size, dstOff, extend int)

Copy ... Copy buffer from src to b as BaseImplt

func (*BaseImpl) D added in v0.1.2

func (b *BaseImpl) D(off, size int) *Diff

D ... return new Diff of buffer for updating

func (*BaseImpl) Dedup added in v0.1.2

func (b *BaseImpl) Dedup()

Dedup ... dedup in b.Diffs

func (*BaseImpl) Dump added in v0.2.0

func (b *BaseImpl) Dump(pos int, opts ...DumpOptFn) (out string)

func (*BaseImpl) Dup added in v0.2.2

func (b *BaseImpl) Dup() (dst IO)

Dup ... return copied Base.

func (*BaseImpl) Equal added in v0.2.0

func (b *BaseImpl) Equal(c *BaseImpl) bool

func (*BaseImpl) Flatten added in v0.1.2

func (b *BaseImpl) Flatten()

Flatten ... Diffs buffer join to bytes

func (*BaseImpl) FlattenWithLen added in v0.1.9

func (b *BaseImpl) FlattenWithLen(l int)

FlattenWithLen ... Diffs buffer join to bytes

func (*BaseImpl) GetDiffs added in v0.1.2

func (b *BaseImpl) GetDiffs() []Diff

GetDiffs ... return Diffs of buffer

func (*BaseImpl) HasIoReader added in v0.1.2

func (b *BaseImpl) HasIoReader() bool

HasIoReader ... Base buffer is reading io.Reader or not.

func (*BaseImpl) Impl added in v0.2.0

func (b *BaseImpl) Impl() *BaseImpl

BaseImpl undocumented

func (*BaseImpl) LenBuf added in v0.1.2

func (b *BaseImpl) LenBuf() int

LenBuf ... size of buffer

func (*BaseImpl) Merge added in v0.1.2

func (b *BaseImpl) Merge()

Merge ... join Diffs buffer to bytes Deprecated: Use Flatten()

func (*BaseImpl) MergeDiffs added in v0.4.1

func (b *BaseImpl) MergeDiffs()

func (*BaseImpl) New added in v0.1.2

func (b *BaseImpl) New(n IO) IO

New ... return new Base Interface (instance is BaseImpl)

func (*BaseImpl) NewFromBytes added in v0.1.4

func (b *BaseImpl) NewFromBytes(bytes []byte) IO

NewFromBytes ... return new BaseImpl instance with byte buffer

func (*BaseImpl) Next added in v0.1.2

func (b *BaseImpl) Next(skip int) IO

Next ... provide next root flatbuffers this is mainly for streaming data.

func (*BaseImpl) R added in v0.1.2

func (b *BaseImpl) R(off int, opts ...OptIO) (result []byte)

R ... is access buffer data Base cannot access byte buffer directly.

func (*BaseImpl) Read added in v0.3.1

func (b *BaseImpl) Read(p []byte) (n int, e error)

func (*BaseImpl) ReadAt added in v0.3.1

func (b *BaseImpl) ReadAt(p []byte, i int64) (int, error)

func (*BaseImpl) SetDiffs added in v0.1.2

func (b *BaseImpl) SetDiffs(d []Diff)

SetDiffs ... set Diffs of buffer

func (*BaseImpl) ShouldCheckBound added in v0.1.2

func (b *BaseImpl) ShouldCheckBound() bool

ShouldCheckBound .. which check bounding of buffer.

func (*BaseImpl) Type added in v0.2.0

func (b *BaseImpl) Type() uint8

func (*BaseImpl) U added in v0.1.2

func (b *BaseImpl) U(off, size int) []byte

U ... return buffer for updating

func (*BaseImpl) Write added in v0.3.1

func (b *BaseImpl) Write(p []byte) (n int, err error)

func (*BaseImpl) WriteAt added in v0.3.1

func (b *BaseImpl) WriteAt(p []byte, oi int64) (n int, err error)

type Bool

type Bool bool

type BufInfo

type BufInfo [2]RawBufInfo

BufInfo is buffer detail infomation information of Base.bytes is stored to 0 indexed information of Base.Diffs is stored to 1 indexed

type Byte

type Byte byte

type CommonList added in v0.1.2

type CommonList struct {
	*CommonNode
	// contains filtered or unexported fields
}

CommonList ... return List for separated data area.

func (*CommonList) Add added in v0.1.2

func (dst *CommonList) Add(src *CommonList) (nList *CommonList, e error)

Add ... if src.Name and dst.Name is the same and list, join header

only support element is table .

func (*CommonList) At added in v0.1.2

func (l *CommonList) At(i int) (*CommonNode, error)

At ... return Element of list

func (*CommonList) DataLen added in v0.1.2

func (l *CommonList) DataLen() int

DataLen ... return data.

func (*CommonList) DataWriter added in v0.1.2

func (l *CommonList) DataWriter() io.Writer

DataWriter ... return DataWriter

func (*CommonList) SetAt added in v0.1.2

func (l *CommonList) SetAt(i int, elm *CommonNode) error

SetAt ... Set Element to list

func (*CommonList) SetDataWriter added in v0.1.2

func (l *CommonList) SetDataWriter(w io.Writer)

SetDataWriter ... set io.Writer for writing data area.

func (*CommonList) VLen added in v0.1.4

func (l *CommonList) VLen() uint32

VLen ... return Len of Virtual Table.

func (*CommonList) WriteDataAll added in v0.1.2

func (l *CommonList) WriteDataAll() (e error)

WriteDataAll ... write all data to datawriter

func (*CommonList) WriteElm added in v0.1.2

func (l *CommonList) WriteElm(elm *CommonNode, pos, size int)

WriteElm ... Set Element to list

type CommonNode

type CommonNode struct {
	*NodeList
	Name           string
	IdxToType      map[int]int
	IdxToTypeGroup map[int]int
	// contains filtered or unexported fields
}

CommonNode ... is node of flatbuffers.

func FromBytes

func FromBytes(bytes []byte) *CommonNode

FromBytes ... return fbs data for []byte Deprecated: use FromByteList()

func Open

func Open(r io.Reader, cap int, opts ...Option) (node *CommonNode)

Open ... Open New CommonNode with io.Reader

func OpenByBuf

func OpenByBuf(buf []byte, opts ...Option) *CommonNode

OpenByBuf ... Open New CommonNode with byte buffer

func (*CommonNode) AllTree

func (node *CommonNode) AllTree() *Tree

AllTree ... return all Tree

func (*CommonNode) CanFollow

func (node *CommonNode) CanFollow(idx int) bool

CanFollow ... check instance on Union.

func (*CommonNode) Count

func (node *CommonNode) Count() int

Count ... count of List node.

func (*CommonNode) CountOfField

func (node *CommonNode) CountOfField() int

CountOfField ... return count of field/attribute

func (*CommonNode) DumpTableWithVTable

func (node *CommonNode) DumpTableWithVTable() string

DumpTableWithVTable ... Dump flatbuffers Table and VTable information.

func (*CommonNode) Equal added in v0.1.9

func (n1 *CommonNode) Equal(n2 *CommonNode) bool

Equal ... return boolan if value is same.

func (*CommonNode) FetchIndex

func (node *CommonNode) FetchIndex()

FetchIndex ... fetching index

func (*CommonNode) FieldAt

func (node *CommonNode) FieldAt(idx int) (cNode *CommonNode)

FieldAt ... return field by field index

func (*CommonNode) FindTree

func (node *CommonNode) FindTree(cond TreeCond) <-chan *Tree

FindTree ... return Tree by condtion function.

func (*CommonNode) FollowUnion

func (node *CommonNode) FollowUnion(idx int) *CommonNode

FollowUnion ... return instance via Union.

func (*CommonNode) InRoot

func (node *CommonNode) InRoot() bool

InRoot ... return true if buffer include Root Node.

func (*CommonNode) Info

func (node *CommonNode) Info() (info Info)

Info ... return information of node

func (*CommonNode) Init

func (node *CommonNode) Init() error

Init ... initialize as CommonNode.

func (*CommonNode) InsertBuf

func (node *CommonNode) InsertBuf(pos, size int)

InsertBuf ... insert buffer in pos position.

func (*CommonNode) InsertSpace

func (node *CommonNode) InsertSpace(pos, size int, isInsert bool)

InsertSpace ... insert buffer in pos position.

func (*CommonNode) IsLeafAt

func (node *CommonNode) IsLeafAt(j int) bool

IsLeafAt ... field has child or not.

func (*CommonNode) IsList

func (node *CommonNode) IsList() bool

IsList ... return true if is List Node.

func (*CommonNode) IsRoot

func (node *CommonNode) IsRoot() bool

IsRoot ... return true if root node.

func (*CommonNode) IsSameType

func (node *CommonNode) IsSameType(idx int, fNode *CommonNode) bool

IsSameType ... return true if type information of field collect. FIXME: should improve for performance

func (*CommonNode) Len

func (node *CommonNode) Len() int

Len ... return len of byte size.

func (*CommonNode) List added in v0.1.5

func (node *CommonNode) List() *List

List ... return List instance if node is List.

func (*CommonNode) RootCommon

func (node *CommonNode) RootCommon() *CommonNode

RootCommon ... return Root Node.

func (*CommonNode) SearchInfo

func (node *CommonNode) SearchInfo(pos int, fn RecFn, condFn CondFn)

SearchInfo ... collect Infomation via traversing. if TraverseInfo is work. removed

func (*CommonNode) SelfAsCommonNode added in v0.1.2

func (node *CommonNode) SelfAsCommonNode() *CommonNode

SelfAsCommonNode ... return self CommonNode used by trick genny.

func (*CommonNode) SetBool

func (node *CommonNode) SetBool(v bool) error

func (*CommonNode) SetByte

func (node *CommonNode) SetByte(v byte) error

func (*CommonNode) SetFieldAt

func (node *CommonNode) SetFieldAt(idx int, fNode *CommonNode) error

SetFieldAt ... set Node to current Node field/attribute

func (*CommonNode) SetFloat32

func (node *CommonNode) SetFloat32(v float32) error

func (*CommonNode) SetFloat64

func (node *CommonNode) SetFloat64(v float64) error

func (*CommonNode) SetInt16

func (node *CommonNode) SetInt16(v int16) error

func (*CommonNode) SetInt32

func (node *CommonNode) SetInt32(v int32) error

func (*CommonNode) SetInt64

func (node *CommonNode) SetInt64(v int64) error

func (*CommonNode) SetInt8

func (node *CommonNode) SetInt8(v int8) error

func (*CommonNode) SetUint16

func (node *CommonNode) SetUint16(v uint16) error

func (*CommonNode) SetUint32

func (node *CommonNode) SetUint32(v uint32) error

func (*CommonNode) SetUint64

func (node *CommonNode) SetUint64(v uint64) error

func (*CommonNode) SetUint8

func (node *CommonNode) SetUint8(v uint8) error

func (*CommonNode) TraverseInfo

func (node *CommonNode) TraverseInfo(pos int, fn TraverseRec, condFn TraverseCond)

TraverseInfo ... traverse Info/ValueInfo of all node.

func (*CommonNode) TraverseInfoSlice

func (node *CommonNode) TraverseInfoSlice(pos int, fn TraverseRec, condFn TraverseCond)

TraverseInfoSlice ... traverse Info/ValueInfo of all list node.

func (*CommonNode) Unmarshal

func (node *CommonNode) Unmarshal(v interface{}) error

Unmarshal ... unmarshal to struct. only work fbs's struct node.

func (*CommonNode) ValueInfo

func (node *CommonNode) ValueInfo(idx int) ValueInfo

ValueInfo ... return infomation of field/attribute of node.

type CondFn

type CondFn func(int, Info) bool

type Diff

type Diff struct {
	Offset int
	// contains filtered or unexported fields
}

Diff is journal for create/update

func NewDiff added in v0.2.1

func NewDiff(o int, data []byte) Diff

NewDiff .. create Diff from outside package

func (*Diff) Equal added in v0.2.0

func (d *Diff) Equal(s *Diff) bool

Equal ... return true if equal

func (Diff) Include added in v0.2.0

func (d Diff) Include(pos int) bool

Include .. check pos with diff range.

func (Diff) Included added in v0.2.3

func (d Diff) Included(pos, size int) bool

func (Diff) Inner added in v0.2.0

func (d Diff) Inner(pos, size int) bool

Inner undocumented

func (Diff) Innerd added in v0.2.3

func (d Diff) Innerd(pos, size int) bool

func (*Diff) Merge added in v0.2.0

func (d *Diff) Merge(s *Diff)

func (*Diff) MergeStable added in v0.4.1

func (d *Diff) MergeStable(s *Diff) bool

MergeStable ... keep nodata hole

type Diffs added in v0.4.1

type Diffs []Diff

type DiffsIndexResult added in v0.4.1

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

type DirectReader added in v0.1.2

type DirectReader struct {
	IO
	// contains filtered or unexported fields
}

DirectReader ... is Base without buffer in data area

func NewDirectReader added in v0.1.2

func NewDirectReader(b IO, r io.ReaderAt) DirectReader

NewDirectReader ... return new DirectReader instance.

func (DirectReader) R added in v0.1.2

func (b DirectReader) R(offset int, opts ...OptIO) (result []byte)

R ... read data.

func (DirectReader) ShouldCheckBound added in v0.1.2

func (b DirectReader) ShouldCheckBound() bool

ShouldCheckBound ... DirectReader is not checking boundary.

func (DirectReader) Type added in v0.2.0

func (b DirectReader) Type() uint8

Type ... type of Base

type Dirty

type Dirty struct {
	Pos int
}

Dirty ... Dirty Deprecated: not use.

type DoubleLayer added in v0.2.0

type DoubleLayer struct {
	*BaseImpl
}

DoubleLayer is BaseImpl with Single Diff

func NewDoubleLayer added in v0.2.0

func NewDoubleLayer(b IO) DoubleLayer

NewDoubleLayer ... return DobuleLayer

func (DoubleLayer) Copy added in v0.2.0

func (b DoubleLayer) Copy(osrc IO, srcOff, size, dstOff, extend int)

func (DoubleLayer) D added in v0.2.0

func (b DoubleLayer) D(off, size int) *Diff

D ... return Diff for write

func (DoubleLayer) Dup added in v0.2.3

func (b DoubleLayer) Dup() (dst IO)

func (DoubleLayer) New added in v0.2.0

func (b DoubleLayer) New(n IO) IO

New ... return new NoLayer instance

func (DoubleLayer) NewFromBytes added in v0.2.0

func (b DoubleLayer) NewFromBytes(bytes []byte) IO

NewFromBytes ... return new NoLayer instance with byte buffer.

func (DoubleLayer) R added in v0.2.0

func (b DoubleLayer) R(off int, opts ...OptIO) []byte

R ... read buffer

func (DoubleLayer) Type added in v0.2.0

func (b DoubleLayer) Type() uint8

Type ... type of Base interface

func (DoubleLayer) U added in v0.2.0

func (b DoubleLayer) U(off, size int) []byte

U ... return buffer for update

type DumpOpt added in v0.2.0

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

type DumpOptFn added in v0.2.0

type DumpOptFn func(opt *DumpOpt)

func OptDumpOut added in v0.2.1

func OptDumpOut(w io.Writer) DumpOptFn

func OptDumpSize added in v0.2.0

func OptDumpSize(size int) DumpOptFn

type ErrorMustRead added in v0.4.1

type ErrorMustRead struct {
	Off  int64
	Size int
}

func (ErrorMustRead) Error added in v0.4.1

func (e ErrorMustRead) Error() string

func (ErrorMustRead) ToParam added in v0.4.1

func (e ErrorMustRead) ToParam() (int, int)

type FieldsDefile

type FieldsDefile struct {
	IdxToTyoe      map[int]int
	IdxToTypeGroup map[int]int
}

type Float32

type Float32 float32

type Float64

type Float64 float64

type GlobalConfig added in v0.2.3

type GlobalConfig struct {
	// contains filtered or unexported fields
}
var CurrentGlobalConfig GlobalConfig = GlobalConfig{/* contains filtered or unexported fields */}

type IO added in v0.4.1

type IO interface {
	Next(skip int) IO
	HasIoReader() bool
	R(off int, opts ...OptIO) []byte
	D(off, size int) *Diff
	C(off, size int, src []byte) error
	Copy(src IO, srcOff, size, dstOff, extend int)
	U(off, size int) []byte
	LenBuf() int
	Merge() // Deprecated: should use Flatten()
	Flatten()
	Dedup()
	ClearValueInfoOnDirty(node *NodeList)

	AddDirty(Dirty)
	GetDiffs() []Diff
	SetDiffs([]Diff)
	ShouldCheckBound() bool
	New(IO) IO
	NewFromBytes([]byte) IO
	Impl() *BaseImpl
	Type() uint8
	Dump(int, ...DumpOptFn) string
	Dup() IO
	// for io interface
	Read([]byte) (int, error)
	ReadAt([]byte, int64) (int, error)
	Write(p []byte) (n int, err error)
	WriteAt([]byte, int64) (int, error)
	// contains filtered or unexported methods
}

IO ... low level buffer

func NewBase

func NewBase(bytes []byte) IO

NewBase initialize Base struct via buffer(buf)

func NewBaseByIO

func NewBaseByIO(rio io.Reader, cap int) IO

type Info

type Info ValueInfo

Info is infotion of flatbuffer's table/struct

func FbsStringInfo

func FbsStringInfo(node *Node) Info

FbsStringInfo ... return Node Infomation for FbsString

type Int16

type Int16 int16

type Int32

type Int32 int32

type Int64

type Int64 int64

type Int8

type Int8 int8

type L2Run added in v0.2.3

type L2Run interface{}

type List added in v0.1.4

type List CommonNode

List ... List Node as CommonNode.

func FromByteList added in v0.1.4

func FromByteList(bytes []byte) *List

FromByteList ... []byte in flatbuffers.

func (*List) Add added in v0.2.3

func (list *List) Add(slist *List) error

func (*List) All added in v0.1.4

func (node *List) All() []*CommonNode

All ... All Element by condtion function

func (*List) At added in v0.1.4

func (node *List) At(i int) (*CommonNode, error)

At ... return Element of list

func (*List) AtWihoutError added in v0.2.3

func (node *List) AtWihoutError(i int) *CommonNode

AtWihoutError ... ignore error

func (*List) Count added in v0.1.4

func (node *List) Count() int

Count ... return count of element in List

func (*List) Find added in v0.1.4

func (node *List) Find(fn func(m *CommonNode) bool) *CommonNode

Find ... Find Element by condtion function

func (*List) First added in v0.1.4

func (node *List) First() (*CommonNode, error)

First ... First Element in List

func (*List) InfoSlice added in v0.1.4

func (node *List) InfoSlice() Info

InfoSlice ... return infomation of List

func (*List) InitList added in v0.1.4

func (node *List) InitList() error

InitList ... initlize List.

func (*List) IsList added in v0.1.4

func (node *List) IsList() bool

IsList ... return true if List is true

func (*List) IsSorted added in v0.2.101

func (node *List) IsSorted(less func(i, j int) bool) (result bool)

IsSorted ... return true if list is sorted

func (*List) Last added in v0.1.4

func (node *List) Last() (*CommonNode, error)

Last ... Last Element in List

func (*List) Len added in v0.2.100

func (node *List) Len() int

func (*List) Less added in v0.2.100

func (node *List) Less(i, j int) bool

func (*List) New added in v0.2.99

func (node *List) New(optFns ...ListOpt) (sub *List)

New ... return new list

if ListOptionge was not set, return empty list
if OptRange was set, return sub list by range

func (*List) SearchIndex added in v0.1.4

func (node *List) SearchIndex(n int, fn func(c *CommonNode) bool) int

SearchIndex ... binary search copy/modify from golang.org/src/sort/search.go

func (*List) SearchInfoSlice added in v0.1.4

func (node *List) SearchInfoSlice(pos int, fn RecFn, condFn CondFn)

SearchInfoSlice ... search list information

func (*List) Select added in v0.1.4

func (node *List) Select(fn func(m *CommonNode) bool) []*CommonNode

Select ... Select Elements by condtion function

func (*List) SelfAsCommonNode added in v0.1.4

func (node *List) SelfAsCommonNode() *CommonNode

SelfAsCommonNode ... return self CommonNode used by trick genny.

func (*List) SetAt added in v0.1.4

func (node *List) SetAt(idx int, elm *CommonNode) error

SetAt ... Set Element to list.

if elm type is  variable length (examply Table). this operation is heavy.
to add list , should use Add()

func (*List) SortBy added in v0.1.4

func (node *List) SortBy(less func(i, j int) bool) error

SortBy ... sort of List

func (*List) Swap added in v0.2.100

func (node *List) Swap(i, j int)

func (*List) SwapAt added in v0.1.4

func (node *List) SwapAt(i, j int) error

SwapAt ... swap data in i and j in List.

func (*List) VLen added in v0.1.4

func (node *List) VLen() uint32

VLen ... return Length of flatbuffers's Virtual Table

type ListOpt added in v0.2.99

type ListOpt func(*ListOption)

func OptRange added in v0.2.99

func OptRange(start, last int) ListOpt

type ListOption added in v0.2.99

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

func DefaultListOpt added in v0.2.99

func DefaultListOpt() ListOption

type ListOpts added in v0.2.99

type ListOpts []ListOpt

func (ListOpts) Apply added in v0.2.99

func (opts ListOpts) Apply(opt *ListOption)

type Log2Option added in v0.2.3

type Log2Option func(*LogOptParam)

func L2F added in v0.4.1

func L2F(fn func()) Log2Option

func L2OptF added in v0.2.3

func L2OptF(fn LogFn) Log2Option

func L2OptFlag added in v0.2.3

func L2OptFlag(level log.LogLevel, filter byte) Log2Option

func L2OptRun added in v0.2.3

func L2OptRun(fn func() L2Run) Log2Option

func L2fmt added in v0.2.3

func L2fmt(s string, vlist ...interface{}) Log2Option

type LogArgs

type LogArgs struct {
	Fmt  string
	Infs []interface{}
}

func F

func F(s string, v ...interface{}) LogArgs

type LogFmtParam added in v0.2.3

type LogFmtParam func() []interface{}

type LogFn

type LogFn func() LogArgs

type LogLevel

type LogLevel = log.LogLevel
const (
	LOG_ERROR LogLevel = iota
	LOG_WARN
	LOG_DEBUG
)
var CurrentLogLevel LogLevel

type LogOptParam added in v0.2.3

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

type LogState added in v0.2.3

type LogState struct {
	// contains filtered or unexported fields
}
var LogCurrentState LogState = LogState{/* contains filtered or unexported fields */}

type NoLayer added in v0.1.2

type NoLayer struct {
	*BaseImpl
}

NoLayer is BaseImpl without journal infomation for perfomance.

func NewNoLayer added in v0.1.2

func NewNoLayer(b IO) NoLayer

NewNoLayer ... return new NoLayer instnace. b must be BaseImpl/NoLayer

func (NoLayer) Copy added in v0.1.2

func (b NoLayer) Copy(osrc IO, srcOff, size, dstOff, extend int)

Copy ... copy buffer from Base

func (NoLayer) D added in v0.1.2

func (b NoLayer) D(off, size int) *Diff

D ... return Diff for write

func (NoLayer) Dup added in v0.2.3

func (b NoLayer) Dup() (dst IO)

Dup ... return copied Base

func (NoLayer) New added in v0.1.2

func (b NoLayer) New(n IO) IO

New ... return new NoLayer instance

func (NoLayer) NewFromBytes added in v0.1.4

func (b NoLayer) NewFromBytes(bytes []byte) IO

NewFromBytes ... return new NoLayer instance with byte buffer.

func (NoLayer) R added in v0.1.2

func (b NoLayer) R(off int, opts ...OptIO) []byte

R ... read buffer

func (NoLayer) Type added in v0.2.0

func (b NoLayer) Type() uint8

Type ... type of Base interface

func (NoLayer) U added in v0.1.2

func (b NoLayer) U(off, size int) []byte

U ... return buffer for update

type Node

type Node struct {
	IO
	Pos  int
	Size int
	TLen uint16
}

Node base struct. Pos is start position of buffer ValueInfos is information of pointted fields

func NewNode

func NewNode(b IO, pos int) *Node

NewNode ... this provide creation of Node Node share buffer in same tree.

Base is buffer
pos is start position in Base's buffer

func NewNode2

func NewNode2(b IO, pos int, noLoadVTable bool) *Node

NewNode2 ... provide skip to initialize Vtable

func (*Node) BaseToNoLayer added in v0.1.2

func (node *Node) BaseToNoLayer()

func (*Node) Bool

func (node *Node) Bool() bool

func (*Node) Byte

func (node *Node) Byte() byte

func (*Node) Bytes

func (node *Node) Bytes() []byte

func (*Node) Float32

func (node *Node) Float32() float32

func (*Node) Float64

func (node *Node) Float64() float64

func (*Node) Int16

func (node *Node) Int16() int16

func (*Node) Int32

func (node *Node) Int32() int32

func (*Node) Int64

func (node *Node) Int64() int64

func (*Node) Int8

func (node *Node) Int8() int8

func (*Node) Table

func (node *Node) Table(idx int) int

func (*Node) TableLen

func (node *Node) TableLen() int

TableLen ... return table length in VTable.

func (*Node) Uint16

func (node *Node) Uint16() uint16

func (*Node) Uint32

func (node *Node) Uint32() uint32

func (*Node) Uint64

func (node *Node) Uint64() uint64

func (*Node) Uint8

func (node *Node) Uint8() uint8

func (*Node) Unmarshal

func (node *Node) Unmarshal(ptr interface{}, setter UnmarshalFn) error

func (*Node) ValueInfoPosBytes

func (node *Node) ValueInfoPosBytes(vIdx int) (info ValueInfo)

ValueInfoPosBytes ... etching vtable position infomation for []byte

func (*Node) ValueInfoPosList

func (node *Node) ValueInfoPosList(vIdx int) (info ValueInfo)

ValueInfoPosList ... etching vtable position infomation for flatbuffers vector

func (*Node) ValueList

func (node *Node) ValueList(vIdx int) NodeList

func (*Node) ValueStruct

func (node *Node) ValueStruct(vIdx int) *Node

func (*Node) ValueTable

func (node *Node) ValueTable(vIdx int) *Node

func (*Node) VirtualTable

func (node *Node) VirtualTable(idx int) int

VirtualTable ... return VTable.

func (*Node) VirtualTableIsZero

func (node *Node) VirtualTableIsZero(idx int) bool

VirtualTableIsZero ... return checking VTable is empty

func (*Node) VirtualTableLen

func (node *Node) VirtualTableLen() int

type NodeList

type NodeList struct {
	*Node
	ValueInfo
}

NodeList is struct for Vector(list) Node

func (*NodeList) Member

func (nList *NodeList) Member(i int) interface{}

mock

type NodePath

type NodePath struct {
	Name string
	Idx  int
}

NodePath is path for traverse data tree

type Noder

type Noder interface {
	IsLeafAt(int) bool
	Info() Info
	ValueInfo(int) ValueInfo
	//FieldAt(int) Noder
	SearchInfo(int, RecFn, CondFn)
}

type OptGlobalConf added in v0.2.3

type OptGlobalConf func(*GlobalConfig)

func OptUseMovOff added in v0.2.3

func OptUseMovOff(t bool) OptGlobalConf

type OptIO added in v0.4.1

type OptIO func(*ParamIO)

func Size added in v0.4.1

func Size(require int) OptIO

type Option added in v0.1.4

type Option func(*OptionState)

func SetDefaultBase added in v0.1.4

func SetDefaultBase(name string) Option

type OptionState added in v0.1.4

type OptionState struct {
	// contains filtered or unexported fields
}
var DefaultOption OptionState = OptionState{
	// contains filtered or unexported fields
}

type ParamIO added in v0.4.1

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

func NewParamOpt added in v0.4.1

func NewParamOpt(opts ...OptIO) (p *ParamIO)

type RawBufInfo

type RawBufInfo struct {
	Len int
	Cap int
}

RawBufInfo ... capacity/length infomation of Base's buffer

type ReaderAt added in v0.4.1

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

func NewReaderAt added in v0.4.1

func NewReaderAt(r io.Reader) ReaderAt

func (ReaderAt) Read added in v0.4.1

func (r ReaderAt) Read(buf []byte) (n int, err error)

func (ReaderAt) ReadAt added in v0.4.1

func (r ReaderAt) ReadAt(buf []byte, off int64) (n int, err error)

ReadAt ... warpiing ReadAt with Read

type ReaderWithAt added in v0.4.1

type ReaderWithAt interface {
	io.Reader
	io.ReaderAt
}

type RecFn

type RecFn func(NodePath, Info)

type ReqestNameField

type ReqestNameField struct {
	Names []string
	// contains filtered or unexported fields
}

type Root

type Root struct {
	*Node
}

Root manage top node of data.

type Searcher

type Searcher interface {
	SearchInfo(int, RecFn, CondFn)
	TraverseInfo(pos int, fn TraverseRec, condFn TraverseCond)
}

type TraverseCond

type TraverseCond func(int, int, int) bool

type TraverseRec

type TraverseRec func(*CommonNode, int, int, int, int)

type Tree

type Tree struct {
	Node   *CommonNode
	Parent *Tree
	Childs []*Tree
}

Tree ... return node tree.

func (Tree) Dump

func (tree Tree) Dump() string

Dump ... dump of node information

func (Tree) DumpAll

func (tree Tree) DumpAll(i int, w io.Writer)

DumpAll ... dump of all node information

func (Tree) Pos

func (t Tree) Pos() int

Pos ... return offset position in buffer.

func (Tree) Size

func (t Tree) Size() int

Size ... return Size in buffer.

type TreeCond

type TreeCond func(*Tree) bool

type Uint16

type Uint16 uint16

type Uint32

type Uint32 uint32

type Uint64

type Uint64 uint64

type Uint8

type Uint8 uint8

type UnionNoder

type UnionNoder interface {
	Info(int) Info
	Member(int) Noder
}

type UnmarshalFn

type UnmarshalFn func(string, reflect.Value) error

type Value

type Value struct {
	*Node
	S int
	E int
}

func (Value) String

func (v Value) String() string

type ValueInfo

type ValueInfo struct {
	Pos  int
	Size int
	VLen uint32
}

ValueInfo is information of flatbuffer's table/struct field

func (ValueInfo) IsNotReady

func (info ValueInfo) IsNotReady() bool

IsNotReady ... already set ValueInfo (field information)

Jump to

Keyboard shortcuts

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