github.com/tobgu/qframe@v0.4.0/internal/template/filters.go (about)

     1  package template
     2  
     3  import (
     4  	"bytes"
     5  )
     6  
     7  const BasicColConstComparison = `
     8  func {{.name}}(index index.Int, column []{{.dataType}}, comp {{.dataType}}, bIndex index.Bool) {
     9  	for i, x := range bIndex {
    10  		if !x {
    11  			bIndex[i] = column[index[i]] {{.operator}} comp
    12  		}
    13  	}
    14  }
    15  `
    16  
    17  const BasicColColComparison = `
    18  func {{.name}}(index index.Int, column []{{.dataType}}, compCol []{{.dataType}}, bIndex index.Bool) {
    19  	for i, x := range bIndex {
    20  		if !x {
    21  			pos := index[i]
    22  			bIndex[i] = column[pos] {{.operator}} compCol[pos]
    23  		}
    24  	}
    25  }
    26  `
    27  
    28  func GenerateFilters(pkgName string, specs []Spec) (*bytes.Buffer, error) {
    29  	return Generate(pkgName, specs, []string{"github.com/tobgu/qframe/internal/index"})
    30  }