types

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddIndent

func AddIndent(code string, numOfIndentations int) string

AddIndent adds indentation to the code.

func Align added in v0.4.0

func Align(v string, l int) string

Align returns spaces needed to align strings.

func Int16Marshal

func Int16Marshal() string

Int16Marshal generates code to marshal varint for int16.

func Int16SizeCode

func Int16SizeCode() string

Int16SizeCode generates code to get size of varint for int16.

func Int16Unmarshal

func Int16Unmarshal(typeName string) string

Int16Unmarshal generates code to unmarshal varint for int16.

func Int32Marshal

func Int32Marshal() string

Int32Marshal generates code to marshal varint for int32.

func Int32SizeCode

func Int32SizeCode() string

Int32SizeCode generates code to get size of varint for int32.

func Int32Unmarshal

func Int32Unmarshal(typeName string) string

Int32Unmarshal generates code to unmarshal varint for int32.

func Int64Marshal

func Int64Marshal() string

Int64Marshal generates code to marshal varint for int64.

func Int64SizeCode

func Int64SizeCode() string

Int64SizeCode generates code to get size of varint for int64.

func Int64Unmarshal

func Int64Unmarshal(typeName string) string

Int64Unmarshal generates code to unmarshal varint for int64.

func MergeTypes added in v0.7.0

func MergeTypes(existingTypes []reflect.Type, newTypes []reflect.Type) []reflect.Type

MergeTypes merges two sets of types.

func UInt16Marshal

func UInt16Marshal() string

UInt16Marshal generates code to marshal varint for uint16.

func UInt16SizeCode

func UInt16SizeCode() string

UInt16SizeCode generates code to get size of varint for uint16.

func UInt16Unmarshal

func UInt16Unmarshal(typeName string) string

UInt16Unmarshal generates code to unmarshal varint for uint16.

func UInt32Marshal

func UInt32Marshal() string

UInt32Marshal generates code to marshal varint for uint32.

func UInt32SizeCode

func UInt32SizeCode() string

UInt32SizeCode generates code to get size of varint for uint32.

func UInt32Unmarshal

func UInt32Unmarshal(typeName string) string

UInt32Unmarshal generates code to unmarshal varint for uint32.

func UInt64Marshal

func UInt64Marshal() string

UInt64Marshal generates code to marshal varint for uint64.

func UInt64SizeCode

func UInt64SizeCode() string

UInt64SizeCode generates code to get size of varint for uint64.

func UInt64Unmarshal

func UInt64Unmarshal(typeName string) string

UInt64Unmarshal generates code to unmarshal varint for uint64.

func Var

func Var(prefix string, varIndex *uint64) string

Var generates unique variable name with provided prefix.

Types

type BuilderFactory

type BuilderFactory interface {
	Dependencies() []reflect.Type
	ConstantSize() uint64
	SizeCodeTemplate(varIndex *uint64) (string, bool)
	MarshalCodeTemplate(varIndex *uint64) string
	UnmarshalCodeTemplate(varIndex *uint64) string
}

BuilderFactory is the interface every type builder must implement.

type BuilderFactoryConstant

type BuilderFactoryConstant interface {
	Dependencies() []reflect.Type
	ConstantSize() uint64
	MarshalCodeTemplate(varIndex *uint64) string
	UnmarshalCodeTemplate(varIndex *uint64) string
}

BuilderFactoryConstant is the relaxed interface implemented by builders representing types requiring only constant size of buffer.

type BuilderFactoryNonConstant

type BuilderFactoryNonConstant interface {
	Dependencies() []reflect.Type
	SizeCodeTemplate(varIndex *uint64) string
	MarshalCodeTemplate(varIndex *uint64) string
	UnmarshalCodeTemplate(varIndex *uint64) string
}

BuilderFactoryNonConstant is the relaxed interface implemented by builders representing types requiring only non-constant size of buffer.

type TypeMap

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

TypeMap implements type mapping required by go code.

func NewTypeMap

func NewTypeMap(pkg string) *TypeMap

NewTypeMap creates new type map.

func (*TypeMap) Import

func (tm *TypeMap) Import(pkg string) string

Import adds package to the list of imports.

func (*TypeMap) Imports

func (tm *TypeMap) Imports() map[string]string

Imports returns the list of collected imports.

func (*TypeMap) TypeName

func (tm *TypeMap) TypeName(t reflect.Type) string

TypeName generates a type name for type.

func (*TypeMap) VarName added in v0.7.0

func (tm *TypeMap) VarName(t reflect.Type, prefix string) string

VarName generates deterministic variable name based on its type.

Jump to

Keyboard shortcuts

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