reflext

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMapper = NewMapperFunc("sqlike", nil)

DefaultMapper :

Functions

func Deref

func Deref(t reflect.Type) reflect.Type

Deref : this is the replacement for reflect.Elem()

func FieldByIndexes

func FieldByIndexes(v reflect.Value, indexes []int) reflect.Value

FieldByIndexes :

func FieldByIndexesReadOnly

func FieldByIndexesReadOnly(v reflect.Value, indexes []int) reflect.Value

FieldByIndexesReadOnly :

func Indirect

func Indirect(v reflect.Value) reflect.Value

Indirect : this is the replacement for reflect.Indirect()

func IndirectInit

func IndirectInit(v reflect.Value) reflect.Value

IndirectInit :

func Init

func Init(v reflect.Value) reflect.Value

Init :

func IsKind

func IsKind(t reflect.Type, k reflect.Kind) bool

IsKind :

func IsNull

func IsNull(v reflect.Value) bool

IsNull :

func IsNullable

func IsNullable(t reflect.Type) bool

IsNullable :

func IsZero

func IsZero(v reflect.Value) bool

IsZero :

func Set

func Set(src, v reflect.Value)

Set :

func TypeOf

func TypeOf(i interface{}) reflect.Type

TypeOf : this is the replacement for reflect.TypeOf()

func ValueOf

func ValueOf(i interface{}) reflect.Value

ValueOf : this is the replacement for reflect.ValueOf()

func Zero

func Zero(t reflect.Type) (v reflect.Value)

Zero :

Types

type Fields

type Fields []StructFielder

Fields :

func (Fields) Len

func (x Fields) Len() int

func (Fields) Less

func (x Fields) Less(i, j int) bool

func (Fields) Swap

func (x Fields) Swap(i, j int)

type FormatFunc

type FormatFunc func(string) string

FormatFunc :

type MapFunc

type MapFunc func(StructFielder) (skip bool)

MapFunc :

type Mapper

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

Mapper :

func NewMapperFunc

func NewMapperFunc(tag string, fmtFunc FormatFunc) *Mapper

NewMapperFunc :

func (*Mapper) CodecByType

func (m *Mapper) CodecByType(t reflect.Type) Structer

CodecByType :

func (*Mapper) FieldByIndexes

func (m *Mapper) FieldByIndexes(v reflect.Value, idxs []int) reflect.Value

FieldByIndexes :

func (*Mapper) FieldByIndexesReadOnly

func (m *Mapper) FieldByIndexesReadOnly(v reflect.Value, idxs []int) reflect.Value

FieldByIndexesReadOnly :

func (*Mapper) FieldByName

func (m *Mapper) FieldByName(v reflect.Value, name string) reflect.Value

FieldByName :

func (*Mapper) LookUpFieldByName

func (m *Mapper) LookUpFieldByName(v reflect.Value, name string) (reflect.Value, bool)

LookUpFieldByName :

func (*Mapper) TraversalsByName

func (m *Mapper) TraversalsByName(t reflect.Type, names []string) (idxs [][]int)

TraversalsByName :

func (*Mapper) TraversalsByNameFunc

func (m *Mapper) TraversalsByNameFunc(t reflect.Type, names []string, fn func(int, []int)) (idxs [][]int)

TraversalsByNameFunc :

type Struct

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

Struct :

func (*Struct) Fields

func (s *Struct) Fields() []StructFielder

Fields :

func (*Struct) GetByTraversal

func (s *Struct) GetByTraversal(index []int) StructFielder

GetByTraversal :

func (*Struct) LookUpFieldByName added in v1.1.1

func (s *Struct) LookUpFieldByName(name string) (StructFielder, bool)

LookUpFieldByName :

func (*Struct) Properties

func (s *Struct) Properties() []StructFielder

Properties :

type StructField

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

StructField :

func (*StructField) Children

func (sf *StructField) Children() []StructFielder

func (*StructField) Index

func (sf *StructField) Index() []int

Index :

func (*StructField) IsEmbedded added in v1.1.1

func (sf *StructField) IsEmbedded() bool

func (*StructField) IsNullable

func (sf *StructField) IsNullable() bool

func (*StructField) Name

func (sf *StructField) Name() string

Name :

func (*StructField) Parent

func (sf *StructField) Parent() StructFielder

Parent :

func (*StructField) ParentByTraversal

func (sf *StructField) ParentByTraversal(cb func(StructFielder) bool) StructFielder

ParentByTraversal :

func (*StructField) Tag

func (sf *StructField) Tag() StructTag

Tag :

func (*StructField) Type

func (sf *StructField) Type() reflect.Type

Type :

type StructFielder added in v1.1.1

type StructFielder interface {
	Name() string // New name of struct field
	Type() reflect.Type
	Index() []int
	Tag() StructTag
	Parent() StructFielder
	ParentByTraversal(cb func(StructFielder) bool) StructFielder
	Children() []StructFielder
	IsNullable() bool
	IsEmbedded() bool
}

type StructMapper added in v1.0.2

type StructMapper interface {
	CodecByType(t reflect.Type) Structer
	FieldByName(v reflect.Value, name string) reflect.Value
	FieldByIndexes(v reflect.Value, idxs []int) reflect.Value
	FieldByIndexesReadOnly(v reflect.Value, idxs []int) reflect.Value
	LookUpFieldByName(v reflect.Value, name string) (reflect.Value, bool)
	TraversalsByName(t reflect.Type, names []string) (idxs [][]int)
	TraversalsByNameFunc(t reflect.Type, names []string, fn func(int, []int)) (idxs [][]int)
}

StructMapper :

type StructTag

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

StructTag :

func (StructTag) Get

func (st StructTag) Get(key string) string

Get :

func (StructTag) LookUp

func (st StructTag) LookUp(key string) (val string, exist bool)

LookUp :

func (StructTag) Name

func (st StructTag) Name() string

Name :

func (StructTag) OriginalName

func (st StructTag) OriginalName() string

OriginalName :

type Structer added in v1.1.1

type Structer interface {
	Fields() []StructFielder
	Properties() []StructFielder
	LookUpFieldByName(name string) (StructFielder, bool)
	GetByTraversal(index []int) StructFielder
}

type Zeroer added in v1.0.2

type Zeroer interface {
	IsZero() bool
}

Jump to

Keyboard shortcuts

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