pce

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFieldGolangType

func GetFieldGolangType(field Field) string

GetFieldGolangType 获取字段的 Golang 类型

Types

type Bool

type Bool bool

func (Bool) Parse

func (slf Bool) Parse(value string) any

func (Bool) TypeName

func (slf Bool) TypeName() string

func (Bool) Zero

func (slf Bool) Zero() any

type Boolean

type Boolean bool

func (Boolean) Parse

func (slf Boolean) Parse(value string) any

func (Boolean) TypeName

func (slf Boolean) TypeName() string

func (Boolean) Zero

func (slf Boolean) Zero() any

type Byte

type Byte byte

func (Byte) Parse

func (slf Byte) Parse(value string) any

func (Byte) TypeName

func (slf Byte) TypeName() string

func (Byte) Zero

func (slf Byte) Zero() any

type Char

type Char int8

func (Char) Parse

func (slf Char) Parse(value string) any

func (Char) TypeName

func (slf Char) TypeName() string

func (Char) Zero

func (slf Char) Zero() any

type Complex128

type Complex128 complex128

func (Complex128) Parse

func (slf Complex128) Parse(value string) any

func (Complex128) TypeName

func (slf Complex128) TypeName() string

func (Complex128) Zero

func (slf Complex128) Zero() any

type Complex64

type Complex64 complex64

func (Complex64) Parse

func (slf Complex64) Parse(value string) any

func (Complex64) TypeName

func (slf Complex64) TypeName() string

func (Complex64) Zero

func (slf Complex64) Zero() any

type Config

type Config interface {
	// GetConfigName 配置名称
	GetConfigName() string
	// GetDisplayName 配置显示名称
	GetDisplayName() string
	// GetDescription 配置描述
	GetDescription() string
	// GetIndexCount 索引数量
	GetIndexCount() int
	// GetFields 获取字段
	GetFields() []DataField
	// GetData 获取数据
	GetData() [][]DataInfo
}

Config 配置解析接口

  • 用于将配置文件解析为可供分析的数据结构
  • 可以在 cs 包中找到内置提供的实现及其模板,例如 cs.XlsxIndexConfig

type DataField

type DataField struct {
	Index      int    // 字段索引
	Name       string // 字段名称
	Desc       string // 字段描述
	Type       string // 字段类型
	ExportType string // 导出类型
}

DataField 配置数据字段

type DataInfo

type DataInfo struct {
	DataField        // 字段
	Value     string // 字段值
}

DataInfo 配置数据

type DataTmpl

type DataTmpl interface {
	// Render 渲染模板
	Render(data map[any]any) (string, error)
}

DataTmpl 数据导出模板

type Double

type Double float64

func (Double) Parse

func (slf Double) Parse(value string) any

func (Double) TypeName

func (slf Double) TypeName() string

func (Double) Zero

func (slf Double) Zero() any

type Exporter

type Exporter struct{}

Exporter 导出器

func NewExporter

func NewExporter() *Exporter

NewExporter 创建导出器

func (*Exporter) ExportData

func (slf *Exporter) ExportData(tmpl DataTmpl, data map[any]any) ([]byte, error)

ExportData 导出数据

func (*Exporter) ExportStruct

func (slf *Exporter) ExportStruct(tmpl Tmpl, tmplStruct ...*TmplStruct) ([]byte, error)

ExportStruct 导出结构

type Field

type Field interface {
	// TypeName 字段类型名称
	TypeName() string
	// Zero 获取零值
	Zero() any
	// Parse 解析
	Parse(value string) any
}

Field 基本字段类型接口

func GetFields

func GetFields() []Field

GetFields 获取所有内置支持的字段

type Float

type Float float32

func (Float) Parse

func (slf Float) Parse(value string) any

func (Float) TypeName

func (slf Float) TypeName() string

func (Float) Zero

func (slf Float) Zero() any

type Float32

type Float32 float32

func (Float32) Parse

func (slf Float32) Parse(value string) any

func (Float32) TypeName

func (slf Float32) TypeName() string

func (Float32) Zero

func (slf Float32) Zero() any

type Float64

type Float64 float64

func (Float64) Parse

func (slf Float64) Parse(value string) any

func (Float64) TypeName

func (slf Float64) TypeName() string

func (Float64) Zero

func (slf Float64) Zero() any

type Int

type Int int

func (Int) Parse

func (slf Int) Parse(value string) any

func (Int) TypeName

func (slf Int) TypeName() string

func (Int) Zero

func (slf Int) Zero() any

type Int16

type Int16 int16

func (Int16) Parse

func (slf Int16) Parse(value string) any

func (Int16) TypeName

func (slf Int16) TypeName() string

func (Int16) Zero

func (slf Int16) Zero() any

type Int32

type Int32 int32

func (Int32) Parse

func (slf Int32) Parse(value string) any

func (Int32) TypeName

func (slf Int32) TypeName() string

func (Int32) Zero

func (slf Int32) Zero() any

type Int64

type Int64 int64

func (Int64) Parse

func (slf Int64) Parse(value string) any

func (Int64) TypeName

func (slf Int64) TypeName() string

func (Int64) Zero

func (slf Int64) Zero() any

type Int8

type Int8 int8

func (Int8) Parse

func (slf Int8) Parse(value string) any

func (Int8) TypeName

func (slf Int8) TypeName() string

func (Int8) Zero

func (slf Int8) Zero() any

type Integer

type Integer int64

func (Integer) Parse

func (slf Integer) Parse(value string) any

func (Integer) TypeName

func (slf Integer) TypeName() string

func (Integer) Zero

func (slf Integer) Zero() any

type Loader

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

Loader 配置加载器

func NewLoader

func NewLoader(fields []Field) *Loader

NewLoader 创建加载器

  • 加载器被用于加载配置表的数据和结构信息

func (*Loader) LoadData

func (slf *Loader) LoadData(config Config) map[any]any

LoadData 加载配置并得到配置数据

func (*Loader) LoadStruct

func (slf *Loader) LoadStruct(config Config) *TmplStruct

LoadStruct 加载结构

type Long

type Long int64

func (Long) Parse

func (slf Long) Parse(value string) any

func (Long) TypeName

func (slf Long) TypeName() string

func (Long) Zero

func (slf Long) Zero() any

type Number

type Number float64

func (Number) Parse

func (slf Number) Parse(value string) any

func (Number) TypeName

func (slf Number) TypeName() string

func (Number) Zero

func (slf Number) Zero() any

type Rune

type Rune rune

func (Rune) Parse

func (slf Rune) Parse(value string) any

func (Rune) TypeName

func (slf Rune) TypeName() string

func (Rune) Zero

func (slf Rune) Zero() any

type Short

type Short int16

func (Short) Parse

func (slf Short) Parse(value string) any

func (Short) TypeName

func (slf Short) TypeName() string

func (Short) Zero

func (slf Short) Zero() any

type String

type String string

func (String) Parse

func (slf String) Parse(value string) any

func (String) TypeName

func (slf String) TypeName() string

func (String) Zero

func (slf String) Zero() any

type Tmpl

type Tmpl interface {
	// Render 渲染模板
	Render(templates ...*TmplStruct) (string, error)
}

Tmpl 配置结构模板接口

type TmplField

type TmplField struct {
	Name   string      // 字段名称
	Desc   string      // 字段描述
	Type   string      // 字段类型
	Struct *TmplStruct // 结构类型字段结构信息
	Index  int         // 字段索引
	// contains filtered or unexported fields
}

TmplField 模板字段

func (*TmplField) IsIndex

func (slf *TmplField) IsIndex() bool

IsIndex 是否是索引字段

func (*TmplField) IsSlice

func (slf *TmplField) IsSlice() bool

IsSlice 是否是切片类型

func (*TmplField) IsStruct

func (slf *TmplField) IsStruct() bool

IsStruct 是否是结构类型

type TmplStruct

type TmplStruct struct {
	Name       string       // 结构名称
	Desc       string       // 结构描述
	Fields     []*TmplField // 字段列表
	IndexCount int          // 索引数量
}

TmplStruct 模板结构

func (*TmplStruct) AllChildren

func (slf *TmplStruct) AllChildren() []*TmplStruct

AllChildren 获取所有子结构

type Uint

type Uint uint

func (Uint) Parse

func (slf Uint) Parse(value string) any

func (Uint) TypeName

func (slf Uint) TypeName() string

func (Uint) Zero

func (slf Uint) Zero() any

type Uint16

type Uint16 uint16

func (Uint16) Parse

func (slf Uint16) Parse(value string) any

func (Uint16) TypeName

func (slf Uint16) TypeName() string

func (Uint16) Zero

func (slf Uint16) Zero() any

type Uint32

type Uint32 uint32

func (Uint32) Parse

func (slf Uint32) Parse(value string) any

func (Uint32) TypeName

func (slf Uint32) TypeName() string

func (Uint32) Zero

func (slf Uint32) Zero() any

type Uint64

type Uint64 uint64

func (Uint64) Parse

func (slf Uint64) Parse(value string) any

func (Uint64) TypeName

func (slf Uint64) TypeName() string

func (Uint64) Zero

func (slf Uint64) Zero() any

type Uint8

type Uint8 uint8

func (Uint8) Parse

func (slf Uint8) Parse(value string) any

func (Uint8) TypeName

func (slf Uint8) TypeName() string

func (Uint8) Zero

func (slf Uint8) Zero() any

type Uintptr

type Uintptr uintptr

func (Uintptr) Parse

func (slf Uintptr) Parse(value string) any

func (Uintptr) TypeName

func (slf Uintptr) TypeName() string

func (Uintptr) Zero

func (slf Uintptr) Zero() any

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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