rstruct

package
v0.0.0-...-bb33fa6 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CommonFlatMode = iota
	NestedFlatMode
)
View Source
const (
	ZeroDefaultValueMode = iota
	NilDefaultValueMode
)

Variables

This section is empty.

Functions

func GetDefaultValue

func GetDefaultValue(mode int, valueType reflect.Type) any

func NewCSVAdapter

func NewCSVAdapter(structType *RTStruct, value reflect.Value) csv.Adapter

Types

type CSVAdapter

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

func (*CSVAdapter) Deref

func (csva *CSVAdapter) Deref() csv.Adapter

func (*CSVAdapter) Field

func (csva *CSVAdapter) Field(index int) csv.Adapter

func (*CSVAdapter) Get

func (csva *CSVAdapter) Get() any

func (*CSVAdapter) GetTag

func (csva *CSVAdapter) GetTag(key string) string

func (*CSVAdapter) IsNil

func (csva *CSVAdapter) IsNil() bool

func (*CSVAdapter) IsPointer

func (csva *CSVAdapter) IsPointer() bool

func (*CSVAdapter) IsStruct

func (csva *CSVAdapter) IsStruct() bool

func (*CSVAdapter) Kind

func (csva *CSVAdapter) Kind() reflect.Kind

func (*CSVAdapter) New

func (csva *CSVAdapter) New() csv.Adapter

func (*CSVAdapter) NumField

func (csva *CSVAdapter) NumField() int

func (*CSVAdapter) Set

func (csva *CSVAdapter) Set(value any)

func (*CSVAdapter) SetBool

func (csva *CSVAdapter) SetBool(value bool)

func (*CSVAdapter) SetFloat

func (csva *CSVAdapter) SetFloat(value float64)

func (*CSVAdapter) SetInt

func (csva *CSVAdapter) SetInt(value int64)

func (*CSVAdapter) SetString

func (csva *CSVAdapter) SetString(value string)

func (*CSVAdapter) SetUint

func (csva *CSVAdapter) SetUint(value uint64)

func (*CSVAdapter) SetValue

func (csva *CSVAdapter) SetValue(value any)

type ExtendOption

type ExtendOption struct {
	// Value of extend type.
	Value any
	// Tag conversion map.
	Tags map[string]string
	// Tags prefix map.
	TagsPrefix map[string]string
	// Use true to remove all tags modifiers.
	IsPureTag bool
	// Uses '.' by default.
	PrefixDelimiter rune
	// Makes the nested structure flat.
	IsFlat bool
	// Use NestedFlatMode to preserve nesting in tags.
	FlatMode int
	// ZeroDefaultValueMode to fill values with zero type values, NilDefaultValueMode to fill all fields with nil.
	DefaultValueMode int
	// List of types that will be ignored in nested logic.
	IgnoreNested []any
}

type RTField

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

func NewRTField

func NewRTField(name string, defaultValue any) *RTField

func (*RTField) AsStruct

func (rvf *RTField) AsStruct() *RTStruct

func (*RTField) GetTag

func (rtf *RTField) GetTag(name string) (string, bool)

func (*RTField) IsStruct

func (rvf *RTField) IsStruct() bool

func (*RTField) Name

func (rtf *RTField) Name() string

func (*RTField) RemoveTag

func (rtf *RTField) RemoveTag(name string)

func (*RTField) SetTag

func (rtf *RTField) SetTag(name string, value string) *RTField

func (*RTField) Tags

func (rtf *RTField) Tags() map[string]string

type RTStruct

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

func NewStruct

func NewStruct() *RTStruct

func (*RTStruct) AddField

func (rts *RTStruct) AddField(field *RTField) error

func (*RTStruct) AddFields

func (rts *RTStruct) AddFields(fields ...*RTField) error

func (*RTStruct) Extend

func (rts *RTStruct) Extend(extendOptions ...ExtendOption) error

func (*RTStruct) FieldByIndex

func (rts *RTStruct) FieldByIndex(index int) *RTField

func (*RTStruct) FieldByName

func (rts *RTStruct) FieldByName(name string) *RTField

func (*RTStruct) New

func (rts *RTStruct) New() *RVStruct

func (*RTStruct) NumField

func (rts *RTStruct) NumField() int

func (*RTStruct) SortedString

func (rts *RTStruct) SortedString() string

func (*RTStruct) String

func (rts *RTStruct) String() string

type RVField

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

func (*RVField) AsStruct

func (rvf *RVField) AsStruct() *RVStruct

func (*RVField) Get

func (rvf *RVField) Get() any

func (*RVField) IsInterface

func (rvf *RVField) IsInterface() bool

func (*RVField) IsMap

func (rvf *RVField) IsMap() bool

func (*RVField) IsNil

func (rvf *RVField) IsNil() bool

func (*RVField) IsPointer

func (rvf *RVField) IsPointer() bool

func (*RVField) IsSlice

func (rvf *RVField) IsSlice() bool

func (*RVField) IsStruct

func (rvf *RVField) IsStruct() bool

func (*RVField) Kind

func (rvf *RVField) Kind() reflect.Kind

func (*RVField) Set

func (rvf *RVField) Set(value any)

func (*RVField) String

func (rvf *RVField) String() string

func (*RVField) ToJson

func (rvf *RVField) ToJson() ([]byte, error)

func (*RVField) Type

func (rvf *RVField) Type() *RTField

type RVStruct

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

func (*RVStruct) FieldByIndex

func (rvs *RVStruct) FieldByIndex(index int) *RVField

func (*RVStruct) FieldByName

func (rvs *RVStruct) FieldByName(name string) *RVField

func (*RVStruct) FieldsListByTag

func (rvs *RVStruct) FieldsListByTag(tag string) []*RVField

func (*RVStruct) FieldsMapByTag

func (rvs *RVStruct) FieldsMapByTag(tag string) map[string]*RVField

func (*RVStruct) String

func (rvs *RVStruct) String() string

func (*RVStruct) ToJson

func (rvs *RVStruct) ToJson(tag string) ([]byte, error)

func (*RVStruct) ToMap

func (rvs *RVStruct) ToMap(tag string) map[string]any

func (*RVStruct) Type

func (rvs *RVStruct) Type() *RTStruct

Jump to

Keyboard shortcuts

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