structag

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MarshalBinary directionT = iota
	UnmarshalBinary
	Size
)

Variables

This section is empty.

Functions

func MethodBuilderList

func MethodBuilderList() map[string]TagPrompter

func RootStructName

func RootStructName() *jen.Statement

Types

type Context added in v0.9.1

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

func (*Context) Flush added in v0.9.1

func (c *Context) Flush() *jen.Statement

flush the content of context state into "m" variable after flush "m" points to the next free byte-aligned position and the context is empty again (static + dynamic bit positions)

type FieldType added in v0.9.1

type FieldType int
const (
	Const FieldType = iota
	RuntimeSize
	SelfContained
)

type StrucTag

type StrucTag struct {
	Type  string
	Order binary.ByteOrder

	Skip bool
	// contains filtered or unexported fields
}

func NewStrucTag

func NewStrucTag(ctx *Context, fieldVal *types.Var, tagVal string, defaultByteorder binary.ByteOrder) (*StrucTag, error)

func (*StrucTag) BinaryToType

func (tag *StrucTag) BinaryToType(goType string, n *jen.Statement) *jen.Statement

func (*StrucTag) ElementBitLen added in v0.9.1

func (t *StrucTag) ElementBitLen() int

func (*StrucTag) FieldBitLen added in v0.9.1

func (t *StrucTag) FieldBitLen() int

Returns size in Bit for the Field occupies in binary representation

func (*StrucTag) FieldType added in v0.9.1

func (t *StrucTag) FieldType() FieldType

func (*StrucTag) GetNewLoopVar

func (t *StrucTag) GetNewLoopVar() (*jen.Statement, *jen.Statement)

Gets a new unique named loop variable name for use in the context of serializing this struct

func (*StrucTag) GetSize

func (tag *StrucTag) GetSize() (*jen.Statement, error)

func (*StrucTag) Pack

func (tag *StrucTag) Pack() (*jen.Statement, error)

func (StrucTag) String

func (t StrucTag) String() string

func (*StrucTag) TypeToBinary

func (tag *StrucTag) TypeToBinary(goType string, n *jen.Statement) *jen.Statement

func (*StrucTag) Unpack

func (tag *StrucTag) Unpack() (*jen.Statement, error)

type TagPrompter

type TagPrompter func(tag *StrucTag) (*jen.Statement, error)

Jump to

Keyboard shortcuts

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