Documentation
¶
Index ¶
- Constants
- Variables
- func FormatStringField(fieldValue string) string
- func UnmarshalData(dataPath string, dataRef interface{}) error
- type Const
- type ExcelSetting
- type FieldOperate
- type LangSetting
- type LangTemp
- type NameRow
- type NameValue
- type OutputCfg
- type ProgramLanguage
- type ProjectBuff
- type ProjectSetting
- type PropertyFileOperate
- type Settings
- type SourceCfg
- type SystemSetting
- func (s *SystemSetting) CheckDataFieldFormat(dataFieldFormat string) bool
- func (s *SystemSetting) CheckDataFileFormat(dataFileFormat string) bool
- func (s *SystemSetting) FindProgramLanguage(lang string) (define *ProgramLanguage, ok bool)
- func (s *SystemSetting) String() string
- func (s *SystemSetting) UpgradeEnvPath(envPath string)
- type TargetCfg
- type TitleData
- func (td TitleData) GetClassInfo(rangeName string) (info NameValue, ok bool)
- func (td TitleData) GetFieldNameInfo(name string) (row NameRow, ok bool)
- func (td TitleData) GetFieldNameRow(name string) int
- func (td TitleData) GetFileKeyInfo(fileName string) (row NameRow, ok bool)
- func (td TitleData) GetFileKeyRow(name string) int
- func (td TitleData) GetOutputInfo(rangeName string) (info TitleDataOutputInfo, ok bool)
- type TitleDataOutputInfo
Constants ¶
View Source
const ( ModeNameTitle = "title" ModeNameData = "data" ModeNameConst = "const" )
View Source
const ( FieldRangeNameClient = "client" FieldRangeNameServer = "server" FieldRangeNameDb = "db" )
View Source
const ( LangNameAs3 = "as3" LangNameCPlus = "c++" LangNameCSharp = "c#" LangNameGo = "go" LangNameJava = "java" LangNameTs = "ts" )
View Source
const ( FileNameBin = "bin" FileNameSql = "sql" FileNameJson = "json" FileNameYaml = "yaml" FileNameYml = "yml" FileNameToml = "toml" FileNameHcl = "hcl" FileNameEnv = "env" FileNameProperties = "properties" )
View Source
const ( FieldBool = "bool" FieldBoolArr = "[]bool" FieldInt8 = "int8" FieldInt8Arr = "[]int8" FieldInt16 = "int16" FieldInt16Arr = "[]int16" FieldInt32 = "int32" FieldInt32Arr = "[]int32" FieldInt64 = "int64" FieldInt64Arr = "[]int64" FieldUint8 = "uint8" FieldUint8Arr = "[]uint8" FieldUint16 = "uint16" FieldUint16Arr = "[]uint16" FieldUint32 = "uint32" FieldUint32Arr = "[]uint32" FieldUint64 = "uint64" FieldUint64Arr = "[]uint64" FieldFloat32 = "float32" FieldFloat32Arr = "[]float32" FieldFloat64 = "float64" FieldFloat64Arr = "[]float64" FieldString = "string" FieldStringArr = "[]string" FieldJson = "json" FieldJsonArr = "[]json" )
Variables ¶
View Source
var ( //RootPath = `D:\workspaces\GoPath\src\github.com\xuzhuoxi\ExcelExporter\res` RootPath = osxu.GetRunningDir() EnvPath = RootPath SystemPath = filex.Combine(EnvPath, "system.yaml") ProjectPath = filex.Combine(EnvPath, "project.yaml") ExcelPath = filex.Combine(EnvPath, "excel.yaml") )
Functions ¶
func FormatStringField ¶
func UnmarshalData ¶
Types ¶
type Const ¶
type Const struct {
// 启用前缀
Prefix string `yaml:"prefix"`
// 导出命名
Outputs []NameValue `yaml:"outputs"`
// 常量导出类信息
Classes []NameValue `yaml:"classes"`
// 常量名
NameCol string `yaml:"name_col"`
// 常量值
ValueCol string `yaml:"value_col"`
// 常量值类型
TypeCol string `yaml:"type_col"`
// 注释
RemarkCol string `yaml:"remark_col"`
// 数据的开始行号
DataStartRow int `yaml:"data_start_row"`
}
type ExcelSetting ¶
要求输出的Sheet
type FieldOperate ¶
type FieldOperate struct {
Name string `yaml:"name"`
Operates []PropertyFileOperate `yaml:"operates"`
}
func (FieldOperate) GetGetOperate ¶
func (o FieldOperate) GetGetOperate(fileName string) string
func (FieldOperate) GetPropertyOperate ¶
func (o FieldOperate) GetPropertyOperate(fileName string) (op PropertyFileOperate, ok bool)
func (FieldOperate) GetSetOperate ¶
func (o FieldOperate) GetSetOperate(fileName string) string
func (FieldOperate) String ¶
func (o FieldOperate) String() string
type LangSetting ¶
type LangSetting struct {
Name string `yaml:"name"`
Bool FieldOperate `yaml:"bool,omitempty"`
Int8 FieldOperate `yaml:"int8,omitempty"`
Int16 FieldOperate `yaml:"int16,omitempty"`
Int32 FieldOperate `yaml:"int32,omitempty"`
Int64 FieldOperate `yaml:"int64,omitempty"`
UInt8 FieldOperate `yaml:"uint8,omitempty"`
UInt16 FieldOperate `yaml:"uint16,omitempty"`
UInt32 FieldOperate `yaml:"uint32,omitempty"`
UInt64 FieldOperate `yaml:"uint64,omitempty"`
Float32 FieldOperate `yaml:"float32,omitempty"`
Float64 FieldOperate `yaml:"float64,omitempty"`
Str FieldOperate `yaml:"string,omitempty"`
Json FieldOperate `yaml:"json,omitempty"`
BoolArr FieldOperate `yaml:"[]bool,omitempty"`
Int8Arr FieldOperate `yaml:"[]int8,omitempty"`
Int16Arr FieldOperate `yaml:"[]int16,omitempty"`
Int32Arr FieldOperate `yaml:"[]int32,omitempty"`
Int64Arr FieldOperate `yaml:"[]int64,omitempty"`
UInt8Arr FieldOperate `yaml:"[]uint8,omitempty"`
UInt16Arr FieldOperate `yaml:"[]uint16,omitempty"`
UInt32Arr FieldOperate `yaml:"[]uint32,omitempty"`
UInt64Arr FieldOperate `yaml:"[]uint64,omitempty"`
Float32Arr FieldOperate `yaml:"[]float32,omitempty"`
Float64Arr FieldOperate `yaml:"[]float64,omitempty"`
StrArr FieldOperate `yaml:"[]string,omitempty"`
JsonArr FieldOperate `yaml:"[]json,omitempty"`
}
func (*LangSetting) GetLangDefine ¶
func (o *LangSetting) GetLangDefine(name string) (format FieldOperate, ok bool)
func (*LangSetting) String ¶
func (o *LangSetting) String() string
type OutputCfg ¶
type ProgramLanguage ¶
type ProgramLanguage struct {
Name string `yaml:"name"`
ExtendName string `yaml:"ext"`
RefPath string `yaml:"ref"`
TempsTitle []string `yaml:"temps_title"`
TempsConst []string `yaml:"temps_const"`
Setting *LangSetting
}
数据结构定义所支持的编程语言定义
func (*ProgramLanguage) GetTempsConstPath ¶
func (o *ProgramLanguage) GetTempsConstPath() string
func (*ProgramLanguage) GetTempsTitlePath ¶
func (o *ProgramLanguage) GetTempsTitlePath() string
func (ProgramLanguage) String ¶
func (o ProgramLanguage) String() string
func (*ProgramLanguage) UpgradePaths ¶
func (o *ProgramLanguage) UpgradePaths(envPath string)
type ProjectBuff ¶
type ProjectBuff struct {
// 数据导出是否使用高位在前
IsBigEndian bool `yaml:"big_endian"`
// 每个token的最大缓冲区
TokenSize int `yaml:"token"`
// 每个item的最大缓冲区
ItemSize int `yaml:"item"`
// 每个sheet的最大缓冲区
SheetSize int `yaml:"sheet"`
}
缓冲区定义
func (ProjectBuff) String ¶
func (b ProjectBuff) String() string
type ProjectSetting ¶
type ProjectSetting struct {
// 默认处理的文件或目录,以”:”开关,或路径中包含”:”的,视为绝对路径
Source SourceCfg `yaml:"source"`
// 输出目录,以”:”开关,或路径中包含”:”的,视为绝对路径,encoding属性作用于字符文件的输出,和字节文件中字符串的编码
Target TargetCfg `yaml:"target"`
// 处理时缓存设置
Buff ProjectBuff `yaml:"buff"`
}
项目配置
func (*ProjectSetting) String ¶
func (ps *ProjectSetting) String() string
func (*ProjectSetting) UpdateSource ¶
func (ps *ProjectSetting) UpdateSource(source string)
func (*ProjectSetting) UpdateTarget ¶
func (ps *ProjectSetting) UpdateTarget(target string)
func (*ProjectSetting) UpgradeEnvPath ¶
func (ps *ProjectSetting) UpgradeEnvPath(envPath string)
type PropertyFileOperate ¶
type PropertyFileOperate struct {
FileName string `yaml:"file_name"`
Get string `yaml:"get,omitempty"`
Set string `yaml:"set,omitempty"`
}
func (*PropertyFileOperate) String ¶
func (o *PropertyFileOperate) String() string
type Settings ¶
type Settings struct {
System *SystemSetting
Project *ProjectSetting
Excel *ExcelSetting
}
func (*Settings) InitLangSetting ¶
type SourceCfg ¶
type SourceCfg struct {
// 目录路径或文件路径
Value []string `yaml:"value"`
// 编码格式(如果需要)
Encoding string `yaml:"encoding"`
// 文件扩展名
ExtName []string `yaml:"ext_name"`
}
func (SourceCfg) CheckFileFormat ¶
func (*SourceCfg) UpgradeEnvPath ¶
type SystemSetting ¶
type SystemSetting struct {
// 数据结构定义所支持的编程语言
Languages []*ProgramLanguage `yaml:"languages"`
// 支持的数据字段格式
// 其中string中的*代表字符数,范围[1,1024]。
// 浮点数最多支持6位小数,而且当数值越大,精度就越低,反之亦然
// 使用浮点数时,如果是负数,序列化为二进制后再读取,部分编程语言会出现抖动现象,如AS3: -2.3 => [-64,19,51,51] => -2.299999952316284
DataFieldFormats []string `yaml:"datafield_formats"`
// 支持的数据文件格式
DataFileFormats []string `yaml:"datafile_formats"`
}
func (*SystemSetting) CheckDataFieldFormat ¶
func (s *SystemSetting) CheckDataFieldFormat(dataFieldFormat string) bool
func (*SystemSetting) CheckDataFileFormat ¶
func (s *SystemSetting) CheckDataFileFormat(dataFileFormat string) bool
func (*SystemSetting) FindProgramLanguage ¶
func (s *SystemSetting) FindProgramLanguage(lang string) (define *ProgramLanguage, ok bool)
func (*SystemSetting) String ¶
func (s *SystemSetting) String() string
func (*SystemSetting) UpgradeEnvPath ¶
func (s *SystemSetting) UpgradeEnvPath(envPath string)
type TargetCfg ¶
type TargetCfg struct {
// 根目录
RootDir string `yaml:"root"`
// 定义目录
Title OutputCfg `yaml:"title"`
// 数据目录
Data OutputCfg `yaml:"data"`
// 常量目录
Const OutputCfg `yaml:"const"`
}
func (*TargetCfg) GetConstDir ¶
func (*TargetCfg) GetDataDir ¶
func (*TargetCfg) GetTitleDir ¶
func (*TargetCfg) UpgradeEnvPath ¶
type TitleData ¶
type TitleData struct {
// 启用前缀
Prefix string `yaml:"prefix"`
// 导出命名
Outputs []TitleDataOutputInfo `yaml:"outputs"`
// 表头导出类信息
Classes []NameValue `yaml:"classes"`
// 数据控制列,决定数据范围
ControlRow int `yaml:"control_row"`
// 字段别名行号,用于查找指定列,值为0时使用列号作为别名
NickRow int `yaml:"nick_row"`
// 数据名称所在行号,与Excel行号一致
NameRow int `yaml:"name_row"`
// 数据注释所在行号,与Excel行号一致
RemarkRow int `yaml:"remark_row"`
// 输出选择行号,内容格式: 'c,s,d',c、s、d的格式只能是0或1,c指前端,s指后端,d指数据库,顺序不能颠倒。从1开始。
FieldRangeRow int `yaml:"field_range_row"`
// 数据格式行号,内容格式支持:
// uint8,uint16,uint32,int8,int16,int32,float32,boolean,string,string(*),
// uint8[],uint16[],uint32[],int8[],int16[],int32[],float32[],boolean[],string[],string(*)[]
FieldFormatRow int `yaml:"field_format_row"`
// 各语言使用的字段名称对应行号
FieldNames []NameRow `yaml:"field_names"`
// 数据文件使用的字段名称行号
FileKeys []NameRow `yaml:"file_keys"`
// 数据的开始行号
DataStartRow int `yaml:"data_start_row"`
}
func (TitleData) GetClassInfo ¶
func (TitleData) GetFieldNameInfo ¶
func (TitleData) GetFieldNameRow ¶
func (TitleData) GetFileKeyInfo ¶
func (TitleData) GetFileKeyRow ¶
func (TitleData) GetOutputInfo ¶
func (td TitleData) GetOutputInfo(rangeName string) (info TitleDataOutputInfo, ok bool)
type TitleDataOutputInfo ¶
type TitleDataOutputInfo struct {
RangeName string `yaml:"range_name"`
TitleFileName string `yaml:"title"`
DataFileName string `yaml:"data"`
}
func (TitleDataOutputInfo) String ¶
func (o TitleDataOutputInfo) String() string
Click to show internal directories.
Click to hide internal directories.