structparser

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 License: AGPL-3.0 Imports: 3 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BottomUpWalk

func BottomUpWalk(node Node, f func(curr Node, children []Node))

BottomUpWalk 自底向上遍历 `node`

Types

type BoolNode

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

BoolNode bool node

func (*BoolNode) Comment

func (n *BoolNode) Comment() string

func (*BoolNode) Compress

func (n *BoolNode) Compress() Node

func (*BoolNode) Extra

func (n *BoolNode) Extra() *interface{}

func (*BoolNode) Name

func (n *BoolNode) Name() string

func (*BoolNode) String

func (n *BoolNode) String() string

func (*BoolNode) Tag

func (n *BoolNode) Tag() reflect.StructTag

func (*BoolNode) Type

func (*BoolNode) Type() NodeType

func (*BoolNode) TypeName

func (n *BoolNode) TypeName() string

type FloatNode

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

FloatNode float node

func (*FloatNode) Comment

func (n *FloatNode) Comment() string

func (*FloatNode) Compress

func (n *FloatNode) Compress() Node

func (*FloatNode) Extra

func (n *FloatNode) Extra() *interface{}

func (*FloatNode) Name

func (n *FloatNode) Name() string

func (*FloatNode) String

func (n *FloatNode) String() string

func (*FloatNode) Tag

func (n *FloatNode) Tag() reflect.StructTag

func (*FloatNode) Type

func (*FloatNode) Type() NodeType

func (*FloatNode) TypeName

func (n *FloatNode) TypeName() string

type Int64Node

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

Int64Node int64 node

func (*Int64Node) Comment

func (n *Int64Node) Comment() string

func (*Int64Node) Compress

func (n *Int64Node) Compress() Node

func (*Int64Node) Extra

func (n *Int64Node) Extra() *interface{}

func (*Int64Node) Name

func (n *Int64Node) Name() string

func (*Int64Node) String

func (n *Int64Node) String() string

func (*Int64Node) Tag

func (n *Int64Node) Tag() reflect.StructTag

func (*Int64Node) Type

func (*Int64Node) Type() NodeType

func (*Int64Node) TypeName

func (n *Int64Node) TypeName() string

type IntNode

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

IntNode int node

func (*IntNode) Comment

func (n *IntNode) Comment() string

func (*IntNode) Compress

func (n *IntNode) Compress() Node

func (*IntNode) Extra

func (n *IntNode) Extra() *interface{}

func (*IntNode) Name

func (n *IntNode) Name() string

func (*IntNode) String

func (n *IntNode) String() string

func (*IntNode) Tag

func (n *IntNode) Tag() reflect.StructTag

func (*IntNode) Type

func (*IntNode) Type() NodeType

func (*IntNode) TypeName

func (n *IntNode) TypeName() string

type MapNode

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

MapNode map node

func (*MapNode) Comment

func (n *MapNode) Comment() string

func (*MapNode) Compress

func (n *MapNode) Compress() Node

func (*MapNode) Extra

func (n *MapNode) Extra() *interface{}

func (*MapNode) Name

func (n *MapNode) Name() string

func (*MapNode) String

func (n *MapNode) String() string

func (*MapNode) Tag

func (n *MapNode) Tag() reflect.StructTag

func (*MapNode) Type

func (*MapNode) Type() NodeType

func (*MapNode) TypeName

func (n *MapNode) TypeName() string

type Node

type Node interface {
	// Name node 的 field name
	Name() string

	// Comment node 的 field comment
	Comment() string

	// Type node 所属 NodeType
	Type() NodeType

	// TypeName node 类型名,e.g. int, time.Time
	TypeName() string

	// Tag node 的 field tag
	Tag() reflect.StructTag

	// String impl fmt.Stringer
	String() string

	// Extra node 中用于放置额外信息的地方,可以用于 Walk 时存放信息
	Extra() *interface{}

	// Compress 压缩 node 中的 Ptr,
	// e.g.
	// ptr(ptr(int)) -> int
	Compress() Node
	// contains filtered or unexported methods
}

Node 所有 Node struct 的公共方法

func Parse

func Parse(structure interface{}) Node

Parse `structure` into structparser.Node

type NodeType

type NodeType int

NodeType Node 类型

const (
	// Bool BoolNode
	Bool NodeType = iota
	// Int IntNode
	Int
	// Int64 Int64Node
	Int64
	// Float FloatNode
	Float
	// Slice SliceNode
	Slice
	// Map MapNode
	Map
	// Ptr PtrNode
	Ptr
	// String StringNode
	String
	// Struct StructNode
	Struct
)

type PtrNode

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

PtrNode pointer node

func (*PtrNode) Comment

func (n *PtrNode) Comment() string

func (*PtrNode) Compress

func (n *PtrNode) Compress() Node

Compress 压缩 PtrNode, 并且将 `inner` 的属性设置为 ptrnode 的属性

func (*PtrNode) Extra

func (n *PtrNode) Extra() *interface{}

func (*PtrNode) Name

func (n *PtrNode) Name() string

func (*PtrNode) String

func (n *PtrNode) String() string

func (*PtrNode) Tag

func (n *PtrNode) Tag() reflect.StructTag

func (*PtrNode) Type

func (*PtrNode) Type() NodeType

func (*PtrNode) TypeName

func (n *PtrNode) TypeName() string

type SliceNode

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

SliceNode slice node, include slice & array

func (*SliceNode) Comment

func (n *SliceNode) Comment() string

func (*SliceNode) Compress

func (n *SliceNode) Compress() Node

func (*SliceNode) Extra

func (n *SliceNode) Extra() *interface{}

func (*SliceNode) Name

func (n *SliceNode) Name() string

func (*SliceNode) String

func (n *SliceNode) String() string

func (*SliceNode) Tag

func (n *SliceNode) Tag() reflect.StructTag

func (*SliceNode) Type

func (*SliceNode) Type() NodeType

func (*SliceNode) TypeName

func (n *SliceNode) TypeName() string

type StringNode

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

StringNode string node

func (*StringNode) Comment

func (n *StringNode) Comment() string

func (*StringNode) Compress

func (n *StringNode) Compress() Node

func (*StringNode) Extra

func (n *StringNode) Extra() *interface{}

func (*StringNode) Name

func (n *StringNode) Name() string

func (*StringNode) String

func (n *StringNode) String() string

func (*StringNode) Tag

func (n *StringNode) Tag() reflect.StructTag

func (*StringNode) Type

func (*StringNode) Type() NodeType

func (*StringNode) TypeName

func (n *StringNode) TypeName() string

type StructNode

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

StructNode struct node

func (*StructNode) Comment

func (n *StructNode) Comment() string

func (*StructNode) Compress

func (n *StructNode) Compress() Node

Compress struct compress 如果 field 是 anonymous 的,且其类型为 struct ,那么将这个 field 的子 fields , 扩展到当前 struct

func (*StructNode) Extra

func (n *StructNode) Extra() *interface{}

func (*StructNode) Name

func (n *StructNode) Name() string

func (*StructNode) String

func (n *StructNode) String() string

func (*StructNode) Tag

func (n *StructNode) Tag() reflect.StructTag

func (*StructNode) Type

func (*StructNode) Type() NodeType

func (*StructNode) TypeName

func (n *StructNode) TypeName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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