model

package
v0.0.0-...-a7dee75 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Generated by github.com/adamluo159/tabtoy Version: 2.7.4 DO NOT EDIT!!

Index

Constants

View Source
const RepeatedKeyword = "repeated"
View Source
const RepeatedKeywordLen = len(RepeatedKeyword)
View Source
const SliceKeyword = "[]"
View Source
const SliceKeywordLen = len(SliceKeyword)
View Source
const TypeSheetName = "@Types"

Variables

View Source
var (
	ErrDuplicateFieldName = errors.New("Duplicate field name")
	ErrDuplicateIndexName = errors.New("Duplicate index name")
)

Functions

func FieldTypeToString

func FieldTypeToString(t FieldType) string

func FieldTypeToTsString

func FieldTypeToTsString(t FieldType) string

func IsSystemTag

func IsSystemTag(tag string) bool

func MakeTag

func MakeTag(t int32, order int32) int32

Types

type Builtin

type Builtin struct {
}

Defined in table: Builtin

type BuiltinTable

type BuiltinTable struct {

	// 表格原始数据
	Builtin
	// contains filtered or unexported fields
}

Builtin 访问接口

func NewBuiltinTable

func NewBuiltinTable() *BuiltinTable

创建一个Builtin表读取实例

func (*BuiltinTable) Load

func (self *BuiltinTable) Load(filename string) error

从json文件加载

func (*BuiltinTable) RegisterIndexEntry

func (self *BuiltinTable) RegisterIndexEntry(name string, indexCallback func(*BuiltinTable), clearCallback func(*BuiltinTable))

注册外部索引入口, 索引回调, 清空回调

type ConditionType

type ConditionType int32

Defined in table: Types

const (

	// 无
	ConditionType_None ConditionType = 0

	// 值存在
	ConditionType_ValueExists ConditionType = 1

	// 值相等
	ConditionType_ValueEqual ConditionType = 2

	// 值范围
	ConditionType_ValueRange ConditionType = 3
)

type DataModel

type DataModel struct {
	Lines     []*LineData
	FieldMark string
}

对应table

func NewDataModel

func NewDataModel(fieldMark string) *DataModel

func (*DataModel) Add

func (self *DataModel) Add(data *LineData)

type Descriptor

type Descriptor struct {
	Name     string
	Kind     DescriptorKind
	Usage    DescriptorUsage
	NotPrint bool

	FieldByName   map[string]*FieldDescriptor
	FieldByNumber map[int32]*FieldDescriptor
	Fields        []*FieldDescriptor

	Indexes     []*FieldDescriptor
	IndexByName map[string]*FieldDescriptor

	File *FileDescriptor
}

func NewDescriptor

func NewDescriptor() *Descriptor

func (*Descriptor) Add

func (self *Descriptor) Add(def *FieldDescriptor) error

func (*Descriptor) FieldByValueAndMeta

func (self *Descriptor) FieldByValueAndMeta(value string) *FieldDescriptor

type DescriptorKind

type DescriptorKind int
const (
	DescriptorKind_None DescriptorKind = iota
	DescriptorKind_Enum
	DescriptorKind_Struct
)

type DescriptorUsage

type DescriptorUsage int
const (
	DescriptorUsage_None          DescriptorUsage = iota
	DescriptorUsage_RowType                       // 每个表的行类型
	DescriptorUsage_CombineStruct                 // 最终使用的合并结构体
)

type FieldDescriptor

type FieldDescriptor struct {
	Name string

	Type FieldType

	Complex *Descriptor // 复杂类型: 枚举或者结构体

	Order int32 // 在Descriptor中的顺序

	Meta *MetaInfo // 扩展字段

	IsRepeated bool

	EnumValue int32 // 枚举值

	Comment string // 注释

	Parent *Descriptor
}

一列的描述

func NewFieldDescriptor

func NewFieldDescriptor() *FieldDescriptor

func (*FieldDescriptor) DefaultValue

func (self *FieldDescriptor) DefaultValue() string

func (*FieldDescriptor) Equal

func (self *FieldDescriptor) Equal(fd *FieldDescriptor) bool

func (*FieldDescriptor) KindString

func (self *FieldDescriptor) KindString() string

func (*FieldDescriptor) ListSpliter

func (self *FieldDescriptor) ListSpliter() string

func (*FieldDescriptor) ParseType

func (self *FieldDescriptor) ParseType(fileD *FileDescriptor, rawstr string) bool

func (*FieldDescriptor) RepeatCheck

func (self *FieldDescriptor) RepeatCheck() bool

func (*FieldDescriptor) String

func (self *FieldDescriptor) String() string

func (*FieldDescriptor) Tag

func (self *FieldDescriptor) Tag() int32

func (*FieldDescriptor) TsTypeString

func (self *FieldDescriptor) TsTypeString() string

自动适配结构体和枚举输出合适的类型, 类型名为go only

func (*FieldDescriptor) TypeString

func (self *FieldDescriptor) TypeString() string

自动适配结构体和枚举输出合适的类型, 类型名为go only

type FieldType

type FieldType int
const (
	FieldType_None   FieldType = 0
	FieldType_Int32  FieldType = 1
	FieldType_Int64  FieldType = 2
	FieldType_UInt32 FieldType = 3
	FieldType_UInt64 FieldType = 4
	FieldType_Float  FieldType = 5
	FieldType_String FieldType = 6
	FieldType_Bool   FieldType = 7
	FieldType_Enum   FieldType = 8
	FieldType_Struct FieldType = 9
	FieldType_Table  FieldType = 10 // 表格, 仅限二进制使用
)

func ParseFieldType

func ParseFieldType(str string) (t FieldType, ok bool)

type FieldValue

type FieldValue struct {
	FieldDef           *FieldDescriptor
	RawValue           string
	R                  int
	C                  int
	SheetName          string
	FileName           string
	FieldRepeatedCount int // repeated拆成多列时, 这样重复列的数量
}

type FileDescriptor

type FileDescriptor struct {
	Name             string
	DescriptorByName map[string]*Descriptor
	Descriptors      []*Descriptor

	Pragma *MetaInfo
}

func NewFileDescriptor

func NewFileDescriptor() *FileDescriptor

func (*FileDescriptor) Add

func (self *FileDescriptor) Add(def *Descriptor) bool

func (*FileDescriptor) MatchTag

func (self *FileDescriptor) MatchTag(tag string) bool

func (*FileDescriptor) RowDescriptor

func (self *FileDescriptor) RowDescriptor() *Descriptor

取行类型的结构

type GlobalChecker

type GlobalChecker interface {
	CheckValueRepeat(fd *FieldDescriptor, value string) bool

	GlobalFileDesc() *FileDescriptor
}

type LineData

type LineData struct {
	Values []*FieldValue
}

对应record

func NewLineData

func NewLineData() *LineData

func (*LineData) Add

func (self *LineData) Add(fv *FieldValue)

func (*LineData) Len

func (self *LineData) Len() int

func (*LineData) Less

func (self *LineData) Less(i, j int) bool

func (*LineData) Swap

func (self *LineData) Swap(i, j int)

type MetaInfo

type MetaInfo struct {
	*golexer.KVPair
}

func NewMetaInfo

func NewMetaInfo() *MetaInfo

func (*MetaInfo) VisitUserMeta

func (self *MetaInfo) VisitUserMeta(callback func(string, interface{}) bool)

type Node

type Node struct {
	*FieldDescriptor

	StructRoot bool // 结构体标记的dummy node

	// 各种类型的值
	Value     string
	EnumValue int32
	Raw       []byte

	Child []*Node // 优先遍历值, 再key

	SugguestIgnore bool //  建议忽略, 非repeated的普通字段导出时, 如果原单元格没填, 这个字段为true
}

func (*Node) AddKey

func (self *Node) AddKey(def *FieldDescriptor) *Node

func (*Node) AddValue

func (self *Node) AddValue(value string) *Node

type Record

type Record struct {
	Nodes []*Node
	// contains filtered or unexported fields
}

func NewRecord

func NewRecord() *Record

func (*Record) NewNodeByDefine

func (self *Record) NewNodeByDefine(def *FieldDescriptor) *Node

type Table

type Table struct {
	LocalFD  *FileDescriptor
	GlobalFD *FileDescriptor
	Recs     []*Record
}

func NewTable

func NewTable() *Table

func (*Table) Add

func (self *Table) Add(r *Record)

func (*Table) Name

func (self *Table) Name() string

type TableTypes

type TableTypes struct {

	//对象类型
	ObjectType string `MustFill:"true"`

	//字段名
	FieldName string `MustFill:"true"`

	//字段类型
	FieldType string `MustFill:"true"`

	//枚举值
	Value string

	//别名
	Alias string

	//默认值
	Default string

	//特性
	Meta string

	//注释
	Comment string
}

Defined in table: Types

type TableVerify

type TableVerify struct {

	//规则名
	RuleName string `MustFill:"true"`

	//条件
	Condition string `MustFill:"true"`

	//字段路径(类型名.字段名)
	FieldPath string `MustFill:"true"`

	//值
	Value string `MustFill:"true"`
}

Defined in table: Types

type ValueRange

type ValueRange struct {

	// 最小
	Min string

	// 最大
	Max string
}

Defined in table: Types

Jump to

Keyboard shortcuts

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