github.com/tobgu/qframe@v0.4.0/internal/bcolumn/generator.go (about) 1 package bcolumn 2 3 import ( 4 "bytes" 5 6 "github.com/tobgu/qframe/filter" 7 "github.com/tobgu/qframe/internal/maps" 8 "github.com/tobgu/qframe/internal/template" 9 ) 10 11 //go:generate qfgenerate -source=bfilter -dst-file=filters_gen.go 12 //go:generate qfgenerate -source=bdoc -dst-file=doc_gen.go 13 14 func spec(name, operator, templateStr string) template.Spec { 15 return template.Spec{ 16 Name: name, 17 Template: templateStr, 18 Values: map[string]interface{}{"name": name, "dataType": "bool", "operator": operator}} 19 } 20 21 func colConstComparison(name, operator string) template.Spec { 22 return spec(name, operator, template.BasicColConstComparison) 23 } 24 25 func colColComparison(name, operator string) template.Spec { 26 return spec(name, operator, template.BasicColColComparison) 27 } 28 29 func GenerateFilters() (*bytes.Buffer, error) { 30 // If adding more filters here make sure to also add a reference to them 31 // in the corresponding filter map so that they can be looked up. 32 return template.GenerateFilters("bcolumn", []template.Spec{ 33 colConstComparison("eq", "=="), // Go eq ("==") differs from qframe eq ("=") 34 colConstComparison("neq", filter.Neq), 35 colColComparison("eq2", "=="), // Go eq ("==") differs from qframe eq ("=") 36 colColComparison("neq2", filter.Neq), 37 }) 38 } 39 40 func GenerateDoc() (*bytes.Buffer, error) { 41 return template.GenerateDocs( 42 "bcolumn", 43 maps.StringKeys(filterFuncs, filterFuncs2), 44 maps.StringKeys(aggregations)) 45 }