Documentation ¶
Overview ¶
Package tdconv converts table definitions to SQL and Go struct etc. Currently this package supports SQL and Go format. You can change the header and footer text as you want. If you want to output with new format, you can do it with creating a new Formatter. And more, if the parsed `Table` data are not enough for you, you can modify them as you want. For usage of this package, see the standard tool below which uses this package. - github.com/takuoki/tdconv/tools/tdconverter
Index ¶
- func Output(f Formatter, ts *TableSet, multi bool, outdir string) error
- type Column
- type Formatter
- type GoFormatOption
- type GoFormatter
- func (f *GoFormatter) Extension() string
- func (f *GoFormatter) Footer(w io.Writer, ts *TableSet)
- func (f *GoFormatter) Fprint(w io.Writer, t *Table)
- func (f *GoFormatter) Header(w io.Writer, ts *TableSet)
- func (f *GoFormatter) TableFooter(w io.Writer, t *Table)
- func (f *GoFormatter) TableHeader(w io.Writer, t *Table)
- type Key
- type ParseOption
- type Parser
- type SQLFormatOption
- type SQLFormatter
- func (f *SQLFormatter) Extension() string
- func (f *SQLFormatter) Footer(w io.Writer, ts *TableSet)
- func (f *SQLFormatter) Fprint(w io.Writer, t *Table)
- func (f *SQLFormatter) Header(w io.Writer, ts *TableSet)
- func (f *SQLFormatter) TableFooter(w io.Writer, t *Table)
- func (f *SQLFormatter) TableHeader(w io.Writer, t *Table)
- type Table
- type TableSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Column ¶
type Column struct { Name string Type string PKey bool NotNull bool Unique bool Index bool Option string Comment string IsCommon bool }
Column is a struct of Column.
type Formatter ¶
type Formatter interface { Fprint(w io.Writer, t *Table) Header(w io.Writer, ts *TableSet) TableHeader(w io.Writer, t *Table) Extension() string }
Formatter is an interface for formatting.
type GoFormatOption ¶
type GoFormatOption func(*GoFormatter) error
GoFormatOption changes some parameters of the GoFormatter.
func GoFooter ¶
func GoFooter(fc func(w io.Writer, ts *TableSet)) GoFormatOption
GoFooter changes the footer.
func GoHeader ¶
func GoHeader(fc func(w io.Writer, ts *TableSet)) GoFormatOption
GoHeader changes the header.
func GoTableFooter ¶
func GoTableFooter(fc func(w io.Writer, t *Table)) GoFormatOption
GoTableFooter changes the footer of each table.
func GoTableHeader ¶
func GoTableHeader(fc func(w io.Writer, t *Table)) GoFormatOption
GoTableHeader changes the header of each table.
type GoFormatter ¶
type GoFormatter struct {
// contains filtered or unexported fields
}
GoFormatter is a formatter to output the table definision as Go struct.
func NewGoFormatter ¶
func NewGoFormatter(options ...GoFormatOption) (*GoFormatter, error)
NewGoFormatter creates a new GoFormatter. You can change some parameters of the GoFormatter with GoFormatOption.
func (*GoFormatter) Extension ¶
func (f *GoFormatter) Extension() string
Extension returns the extension of Go file.
func (*GoFormatter) Fprint ¶
func (f *GoFormatter) Fprint(w io.Writer, t *Table)
Fprint outputs the table definision as Go struct.
func (*GoFormatter) TableFooter ¶
func (*GoFormatter) TableHeader ¶
type ParseOption ¶
ParseOption changes some parameters of the Parser.
func BoolString ¶
func BoolString(str string) ParseOption
BoolString changes the bool string in the sheet.
func KeyNameFunc ¶
func KeyNameFunc(f func(string) string) ParseOption
KeyNameFunc changes the function to convert the column name to the key name.
func TableNamePos ¶
func TableNamePos(row int, clm string) ParseOption
TableNamePos changes the position (row and column) of table name.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is a struct to parse the sheet values to the table object. Create it using NewParser function.
func NewParser ¶
func NewParser(options ...ParseOption) (*Parser, error)
NewParser creates a new Parser. You can change some parameters of the Parser with ParseOption.
type SQLFormatOption ¶
type SQLFormatOption func(*SQLFormatter) error
SQLFormatOption changes some parameters of the SQLFormatter.
func SQLFooter ¶
func SQLFooter(fc func(w io.Writer, ts *TableSet)) SQLFormatOption
SQLFooter changes the footer.
func SQLHeader ¶
func SQLHeader(fc func(w io.Writer, ts *TableSet)) SQLFormatOption
SQLHeader changes the header.
func SQLTableFooter ¶
func SQLTableFooter(fc func(w io.Writer, t *Table)) SQLFormatOption
SQLTableFooter changes the footer of each table.
func SQLTableHeader ¶
func SQLTableHeader(fc func(w io.Writer, t *Table)) SQLFormatOption
SQLTableHeader changes the header of each table.
type SQLFormatter ¶
type SQLFormatter struct {
// contains filtered or unexported fields
}
SQLFormatter is a formatter to output the table definision as SQL.
func NewSQLFormatter ¶
func NewSQLFormatter(options ...SQLFormatOption) (*SQLFormatter, error)
NewSQLFormatter creates a new SQLFormatter. You can change some parameters of the SQLFormatter with SQLFormatOption.
func (*SQLFormatter) Extension ¶
func (f *SQLFormatter) Extension() string
Extension returns the extension of SQL file.
func (*SQLFormatter) Fprint ¶
func (f *SQLFormatter) Fprint(w io.Writer, t *Table)
Fprint outputs the table definision as SQL.