Documentation
¶
Index ¶
- func IsPrimitive(name string) bool
- type Field
- type Node
- func CreateArrayNode(len uint64, parent *Node) *Node
- func CreateIdentNode(ident *ast.Ident, parent *Node) *Node
- func CreateMapNode(parent *Node) *Node
- func CreatePointerNode(parent *Node) *Node
- func CreateSliceNode(parent *Node) *Node
- func CreateStructNode(importPath, packageName, structName string, parent *Node) *Node
- func (n Node) CanGenerate(structures []*Structure) (bool, []string)
- func (n Node) Elm() *Node
- func (n *Node) GetPointerInfo() (ptrCount int, isParentTypeArrayOrMap bool)
- func (n Node) HasParent() bool
- func (n Node) IsArray() bool
- func (n Node) IsIdentical() bool
- func (n Node) IsMap() bool
- func (n Node) IsParentPointer() bool
- func (n Node) IsPointer() bool
- func (n Node) IsSlice() bool
- func (n Node) IsStruct() bool
- func (n Node) KeyValue() (*Node, *Node)
- func (n *Node) SetKeyNode(key *Node)
- func (n *Node) SetValueNode(value *Node)
- func (n Node) TypeJenChain(structures []*Structure, statements ...*Statement) *Statement
- type Structure
- func (st *Structure) CalcArraySizeFuncName() string
- func (st *Structure) CalcMapSizeFuncName() string
- func (st *Structure) CreateCode(f *File)
- func (st *Structure) DecodeArrayFuncName() string
- func (st *Structure) DecodeMapFuncName() string
- func (st *Structure) EncodeArrayFuncName() string
- func (st *Structure) EncodeMapFuncName() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPrimitive ¶
IsPrimitive returns true, if name matches any case.
Types ¶
type Node ¶
type Node struct {
// for identical
IdenticalName string
// for array
ArrayLen uint64
// for struct
ImportPath string
PackageName string
StructName string
// for array / map / pointer
Key *Node
Value *Node
Parent *Node
// contains filtered or unexported fields
}
Node is a collection of field information.
func CreateArrayNode ¶
CreateArrayNode creates a node of array type.
func CreateIdentNode ¶
CreateIdentNode creates a node of ident type.
func CreateMapNode ¶
CreateMapNode creates a node of map type.
func CreatePointerNode ¶
CreatePointerNode creates a node of pointer type.
func CreateSliceNode ¶
CreateSliceNode creates a node of slice type.
func CreateStructNode ¶
CreateStructNode creates a node of struct type.
func (Node) CanGenerate ¶
CanGenerate return true, if it satisfied conditions by this node.
func (*Node) GetPointerInfo ¶
GetPointerInfo gets some pointer information to create codes.
func (Node) IsIdentical ¶
IsIdentical returns true, if field-type is ident.
func (Node) IsParentPointer ¶
IsParentPointer returns true, if HasParent is true and parent node is pointer.
func (*Node) SetValueNode ¶
SetValueNode sets node to value field.
func (Node) TypeJenChain ¶
TypeJenChain is a helper method to create code.
type Structure ¶
type Structure struct {
ImportPath string
Package string
Name string
Fields []Field
NoUseQual bool
Others []*Structure
File *ast.File
CanGen bool
Reasons []string
}
Structure has information needed for code generation
func (*Structure) CalcArraySizeFuncName ¶
CalcArraySizeFuncName gets the function name for each structure
func (*Structure) CalcMapSizeFuncName ¶
CalcMapSizeFuncName gets the function name for each structure
func (*Structure) CreateCode ¶
func (st *Structure) CreateCode(f *File)
CreateCode creates codes to serialize structure
func (*Structure) DecodeArrayFuncName ¶
DecodeArrayFuncName gets the function name for each structure
func (*Structure) DecodeMapFuncName ¶
DecodeMapFuncName gets the function name for each structure
func (*Structure) EncodeArrayFuncName ¶
EncodeArrayFuncName gets the function name for each structure
func (*Structure) EncodeMapFuncName ¶
EncodeMapFuncName gets the function name for each structure