stream_parser

package
v1.3.5-beta4 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CfgIsTerminal          = "isTerminal"
	CfgIsList              = "list"
	CfgIsTempRoot          = "temp root"
	CfgLength              = "length"
	CfgUnit                = "unit"
	CfgType                = "type"
	CfgGetResult           = "get result"
	CfgRawResult           = "raw result"
	CfgRootMap             = "rootNodeMap"
	CfgEndian              = "endian"
	CfgOperator            = "operator"
	CfgInList              = "inList"
	CfgParent              = "parent"
	CfgDel                 = "del"
	CfgDelimiter           = "delimiter"
	CfgImport              = "import"
	CfgNodeResult          = "node result"
	CfgLastNode            = "last node"
	CfgElementIndex        = "element index"
	CfgExceptionPlan       = "exception-plan"
	CtxGenReaders          = "readers in generator"
	CfgIsRefType           = "is ref type"
	CfgRefType             = "ref-type"
	CfgLengthFromField     = "length-from-field"
	CfgLengthForStartField = "length-for-start-field"
	CfgLengthForField      = "length-for-field"
	CfgStopValue           = "stop-value"
	CfgLengthCacheMap      = "length-cache-map"
)
View Source
const (
	ParserMode    = "parser"
	GeneratorMode = "geneartor"
)

Variables

This section is empty.

Functions

func AnyToInt64

func AnyToInt64(d any) int64

func AnyToUint64

func AnyToUint64(d any) uint64

func CalcNodeResultLength

func CalcNodeResultLength(node *base.Node) uint64

func ConvertToBytes

func ConvertToBytes(v any, length uint64, endian string) ([]byte, error)

func ConvertToVar

func ConvertToVar(v []byte, length uint64, endian, typeName string) any

func ExecInput

func ExecInput(node *base.Node) (res any, err error)

func ExecOperator

func ExecOperator(node *base.Node, code string, operator func(node *base.Node) (func(bool), error)) error

func ExecOut

func ExecOut(node *base.Node) (res *base.NodeValue, err error)

func ExecParser

func ExecParser(node *base.Node) (res any, err error)

func GetBytesByNode

func GetBytesByNode(node *base.Node) []byte

func GetNodePath

func GetNodePath(node *base.Node) string

func GetNodeResult

func GetNodeResult(node *base.Node) any

func GetNodeResultPos

func GetNodeResultPos(node *base.Node) [2]uint64

func GetParentLengthCache added in v1.3.2

func GetParentLengthCache(parentNode *base.Node, childName string) (uint64, bool)

func GetParentNode

func GetParentNode(node *base.Node) *base.Node

func GetResultByNode

func GetResultByNode(node *base.Node) any

func GetSubNodes

func GetSubNodes(node *base.Node) []*base.Node

func InitNode

func InitNode(node *base.Node) error

func IsNumber

func IsNumber(d any) bool

func ListNodeNewElement

func ListNodeNewElement(node *base.Node) (*base.Node, error)

func NewNodeByType

func NewNodeByType(node *base.Node, typeName string) (*base.Node, error)

func NodeHasResult

func NodeHasResult(node *base.Node) bool

func NodeIsDelimiter

func NodeIsDelimiter(node *base.Node) bool

func NodeIsTerminal

func NodeIsTerminal(node *base.Node) bool

func ParseRefNode

func ParseRefNode(node *base.Node) (*base.Node, error)

func SetParentLengthCache added in v1.3.2

func SetParentLengthCache(parentNode *base.Node, childName string, l uint64)

func ToMap

func ToMap(node *base.Node) (*base.NodeValue, error)

Types

type DefParser

type DefParser struct {
	base.BaseParser
	// contains filtered or unexported fields
}

func (*DefParser) Generate

func (d *DefParser) Generate(data any, node *base.Node) error

func (*DefParser) OnRoot

func (d *DefParser) OnRoot(node *base.Node) error

OnRoot 设置了Ctx: root、rootNodeMap; Cfg:parent、lastNode,writer,buffer、isTerminal

func (*DefParser) Operate

func (d *DefParser) Operate(operator *Operator, node *base.Node) error

func (*DefParser) Parse

func (d *DefParser) Parse(data *base.BitReader, node *base.Node) error

func (*DefParser) Result

func (d *DefParser) Result(node *base.Node) (*base.NodeValue, error)

type Operator

type Operator struct {
	ParseStruct   func(node *base.Node) (bool, error)
	ParseTerminal func(node *base.Node) error
	NodeParse     func(node *base.Node) error
	Mode          string
	Backup        func() error
	Recovery      func() error
	PopBackup     func() error
}

type YakNode

type YakNode struct {
	Process              func() any
	Result               func() any
	Name                 string
	SetCfg               func(k string, v any)
	GetCfg               func(k string) any
	AppendNode           func(d *YakNode)
	ForEachChild         func(f func(child *YakNode))
	GetParent            func() *YakNode
	GetSubNode           func(name string) *YakNode
	GetRemainingSpace    func() uint64
	CalcNodeResultLength func() uint64
	NewElement           func() *YakNode

	SetChildren       func([]*YakNode)
	GetChildren       func() []*YakNode
	Length            func(uint ...string) uint64
	SetMaxLength      func(l uint64, uint ...string)
	GetMaxLength      func(uint ...string) uint64
	NewSubNode        func(datas ...any) *YakNode
	NewUnknownNode    func(name ...string) *YakNode
	NewEmptyNode      func(name ...string) *YakNode
	ProcessSubNode    func(name string) any
	TryProcessSubNode func(name string) (any, map[string]any)
	ProcessByType     func(datas ...any) any
	TryProcessByType  func(datas ...string) (any, map[string]any)
	AddInfo           func(key string, v any)
	GetInfo           func(key string) any
	// contains filtered or unexported fields
}

func ConvertToYakNode

func ConvertToYakNode(node *base.Node, operator func(node *base.Node) (func(bool), error)) *YakNode

Jump to

Keyboard shortcuts

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