model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuiltinSymbolsVisible bool
View Source
var (
	FieldTypes = []*FieldType{
		{"int16", "int16", "Int16", "int", "0"},
		{"int32", "int32", "Int32", "int", "0"},
		{"int64", "int64", "Int64", "long", "0"},
		{"int", "int32", "Int32", "int", "0"},
		{"uint16", "uint16", "UInt16", "int", "0"},
		{"uint32", "uint32", "UInt32", "int", "0"},
		{"uint64", "uint64", "UInt64", "long", "0"},
		{"float", "float32", "float", "float", "0"},
		{"double", "float64", "double", "double", "0"},
		{"float32", "float32", "float", "float", "0"},
		{"float64", "float64", "double", "double", "0"},
		{"bool", "bool", "bool", "boolean", "FALSE"},
		{"string", "string", "string", "String", ""},
	}
)

Functions

func FetchDefaultValue

func FetchDefaultValue(fieldType string) (ret string)

取类型的默认值

func InitBuiltinTypes

func InitBuiltinTypes(typeTab *TypeTable)

func LanguagePrimitive

func LanguagePrimitive(fieldType string, lanType string) string

将类型转为对应语言的原始类型

func PrimitiveExists

func PrimitiveExists(fieldType string) bool

原始类型是否存在,例如: int32, int64

Types

type Cell

type Cell struct {
	Value string
	Row   int // base 0
	Col   int // base 0
	Table *DataTable

	Next *Cell // 多列数组中,多个数值保存到一行

}

func (*Cell) CopyFrom

func (self *Cell) CopyFrom(c *Cell)

全拷贝

func (*Cell) String

func (self *Cell) String() string

type DataRow

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

func (*DataRow) AddCell

func (self *DataRow) AddCell() (ret *Cell)

func (*DataRow) Cell

func (self *DataRow) Cell(col int) *Cell

func (*DataRow) Cells

func (self *DataRow) Cells() []*Cell

func (*DataRow) IsEmpty

func (self *DataRow) IsEmpty() bool

type DataTable

type DataTable struct {
	HeaderType string // 表名,Index表里定义的类型

	OriginalHeaderType string // HeaderFields对应的ObjectType,KV表为TableField

	FileName string

	SheetName string

	Rows []*DataRow // 0下标为表头数据

	Headers []*HeaderField
}

表格的完整数据,表头有屏蔽时,对应行值为空

func NewDataTable

func NewDataTable() *DataTable

func (*DataTable) AddCell

func (self *DataTable) AddCell(row int) *Cell

func (*DataTable) AddRow

func (self *DataTable) AddRow() (row int)

func (*DataTable) DataRowIndex

func (self *DataTable) DataRowIndex() (ret []int)

模板用,排除表头的数据索引

func (*DataTable) GetCell

func (self *DataTable) GetCell(row, col int) *Cell

代码生成专用

func (*DataTable) GetValueByName

func (self *DataTable) GetValueByName(row int, name string) *Cell

根据列头找到该行对应的值

func (*DataTable) HeaderByColumn

func (self *DataTable) HeaderByColumn(col int) *HeaderField

func (*DataTable) HeaderByName

func (self *DataTable) HeaderByName(name string) *HeaderField

func (*DataTable) MustGetCell

func (self *DataTable) MustGetCell(row, col int) *Cell

func (*DataTable) MustGetHeader

func (self *DataTable) MustGetHeader(col int) (header *HeaderField)

func (*DataTable) String

func (self *DataTable) String() string

type DataTableList

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

func (*DataTableList) AddDataTable

func (self *DataTableList) AddDataTable(t *DataTable)

func (*DataTableList) AllTables

func (self *DataTableList) AllTables() []*DataTable

func (*DataTableList) Count

func (self *DataTableList) Count() int

func (*DataTableList) GetDataTable

func (self *DataTableList) GetDataTable(headerType string) *DataTable

type FieldType

type FieldType struct {
	InputFieldName string `tb_name:"输入字段"`
	GoFieldName    string `tb_name:"Go字段"`
	CSFieldName    string `tb_name:"C#字段"`
	JavaFieldName  string `tb_name:"Java字段"`
	DefaultValue   string `tb_name:"默认值"`
}

type Globals

type Globals struct {
	Version           string // 工具版本号
	IndexFile         string // 指示文件
	PackageName       string // 文件生成时的包名
	CombineStructName string // 包含最终表所有数据的根结构

	IndexGetter helper.FileGetter // 索引文件获取器
	TableGetter helper.FileGetter // 其他文件获取器

	IndexList []*IndexDefine // 输入的索引文件

	Types *TypeTable // 输入的类型及符号

	Datas DataTableList // 输出的字符串格式的数据表

	GenBinary bool

	MatchTag string

	ParaLoading bool
	UseGBKCSV   bool
}

func NewGlobals

func NewGlobals() *Globals

type HeaderField

type HeaderField struct {
	Cell     *Cell       // 表头单元格内容
	TypeInfo *TypeDefine // 在类型表中找到对应的类型信息
}

func (*HeaderField) String

func (self *HeaderField) String() string

type IndexDefine

type IndexDefine struct {
	Kind          TableKind `tb_name:"模式"`
	TableType     string    `tb_name:"表类型"`
	TableFileName string    `tb_name:"表文件名"`
	Tags          []string  `tb_name:"标记"` // | 分割
}

func (*IndexDefine) MatchTag

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

type TableKind

type TableKind int32
const (
	TableKind_None     TableKind = iota //
	TableKind_Type                      // 类型表
	TableKind_Data                      // 数据表
	TableKind_KeyValue                  // 键值表
)

type TypeData

type TypeData struct {
	Define *TypeDefine
	Tab    *DataTable // 类型引用的表
	Row    int        // 类型引用的原始数据(DataTable)中的行
}

type TypeDefine

type TypeDefine struct {
	Kind          TypeUsage `tb_name:"种类"`
	ObjectType    string    `tb_name:"对象类型"`
	Name          string    `tb_name:"标识名"`
	FieldName     string    `tb_name:"字段名"`
	FieldType     string    `tb_name:"字段类型"`
	Value         string    `tb_name:"值" json:",omitempty"`
	ArraySplitter string    `tb_name:"数组切割" json:",omitempty"`
	MakeIndex     bool      `tb_name:"索引" json:",omitempty"`
	IsBuiltin     bool      `json:",omitempty"`
}

func (*TypeDefine) IsArray

func (self *TypeDefine) IsArray() bool

type TypeTable

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

func NewSymbolTable

func NewSymbolTable() *TypeTable

func (*TypeTable) AddField

func (self *TypeTable) AddField(tf *TypeDefine, data *DataTable, row int)

refData,类型表对应源表的位置信息

func (*TypeTable) AllFieldByName

func (self *TypeTable) AllFieldByName(objectType string) (ret []*TypeDefine)

对象的所有字段

func (*TypeTable) AllFields

func (self *TypeTable) AllFields(all bool) (ret []*TypeDefine)

func (*TypeTable) EnumNames

func (self *TypeTable) EnumNames() (ret []string)

func (*TypeTable) FieldByName

func (self *TypeTable) FieldByName(objectType, name string) (ret *TypeDefine)

数据表中表头对应类型表

func (*TypeTable) IsEnumKind

func (self *TypeTable) IsEnumKind(objectType string) bool

类型是枚举

func (*TypeTable) ObjectExists

func (self *TypeTable) ObjectExists(objectType string) bool

func (*TypeTable) Print

func (self *TypeTable) Print(all bool)

func (*TypeTable) Raw

func (self *TypeTable) Raw() []*TypeData

func (*TypeTable) ResolveEnumValue

func (self *TypeTable) ResolveEnumValue(objectType, value string) string

匹配枚举值

func (*TypeTable) StructNames

func (self *TypeTable) StructNames() (ret []string)

func (*TypeTable) ToJSON

func (self *TypeTable) ToJSON(all bool) []byte

type TypeUsage

type TypeUsage int32
const (
	TypeUsage_None         TypeUsage = iota //
	TypeUsage_HeaderStruct                  // 表头
	TypeUsage_Enum                          // 枚举
)

func (TypeUsage) String

func (self TypeUsage) String() string

Jump to

Keyboard shortcuts

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