core

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEndOfRow = errors.New("End of row")

Functions

func RegisterComponent

func RegisterComponent(name string, builder ComponentBuilder)

func RegisterDatasource

func RegisterDatasource(name string, ds DataSourceBuilder)

func RegisterExporter

func RegisterExporter(name string, exporter Exporter)

Types

type Band

type Band struct {
	Top        float64
	Height     float64
	AutoSize   bool
	Components []Component
}

type Component

type Component interface {
	GetType() string
	GetLeft() float64
	GetTop() float64
	GetWidth() float64
	GetHeight() float64
	GetPrintOn() string
}

type ComponentBuilder

type ComponentBuilder interface {
	Build(template map[string]interface{}, rpt *Keireport) (Component, error)
	Update(comp interface{}, rpt *Keireport) error
}

type DataSource

type DataSource interface {
	SetConfig(data map[string]interface{}) error
	Next(rpt *Keireport) (map[string]interface{}, error)
}

type DataSourceBuilder

type DataSourceBuilder interface {
	Build(data map[string]interface{}) (DataSource, error)
}

type Exporter

type Exporter interface {
	IsHandling(fileName string) bool
	ExportToFile(report *Keireport, fileName string) error
	Export(report *Keireport) ([]byte, error)
}

type Keireport

type Keireport struct {
	BaseDir     string
	SQLDB       *sql.DB
	Debug       bool
	UnitLength  string
	PageSize    string
	PageWidth   float64
	PageHeight  float64
	Orientation string
	Margin      *Margin
	Params      []*Parameter
	Vars        []*Variable
	MaxHeight   float64
	Template    map[string]interface{}
	CurrRow     map[string]interface{}
	Fonts       map[string]string
	DataSource  DataSource
	Pages       []*Page
	CurrentPage *Page
	Resources   map[string]ResourceItem
}

func (*Keireport) AddResource added in v0.1.3

func (o *Keireport) AddResource(name, mime string, data []byte)

func (*Keireport) Build

func (o *Keireport) Build() error

func (*Keireport) BuildBand

func (o *Keireport) BuildBand(bandTemplate map[string]interface{}) error

func (*Keireport) ExecScript

func (o *Keireport) ExecScript(script string) (interface{}, error)

func (*Keireport) GenToFile

func (o *Keireport) GenToFile(fileName string) error

func (*Keireport) Generate

func (o *Keireport) Generate(format string) ([]byte, error)

func (*Keireport) GetResource

func (o *Keireport) GetResource(name string) ([]byte, string)

func (*Keireport) GetResourceFileName added in v0.1.3

func (o *Keireport) GetResourceFileName(fileName string) string

func (*Keireport) LoadFromFile

func (o *Keireport) LoadFromFile(fileName string) error

func (*Keireport) LoadFromString

func (o *Keireport) LoadFromString(templateString, baseDir string) error

func (*Keireport) NewPage

func (o *Keireport) NewPage()

func (*Keireport) ReplaceString

func (o *Keireport) ReplaceString(data string) string

func (*Keireport) SetDBConn

func (o *Keireport) SetDBConn(db *sql.DB)

func (*Keireport) SetParam

func (o *Keireport) SetParam(name string, value interface{})

type Margin

type Margin struct {
	Left   float64
	Right  float64
	Top    float64
	Bottom float64
}

func (*Margin) Init

func (o *Margin) Init(config map[string]interface{})

type Page

type Page struct {
	Bands []*Band
}

type Parameter

type Parameter struct {
	Name       string
	Type       string
	DefaultVal interface{}
	Value      interface{}
}

func (*Parameter) GetBool

func (o *Parameter) GetBool(defValue ...bool) bool

func (*Parameter) GetFloat

func (o *Parameter) GetFloat(defValue ...float64) float64

func (*Parameter) GetInt

func (o *Parameter) GetInt(defValue ...int) int

func (*Parameter) GetString

func (o *Parameter) GetString(defValue ...string) string

func (*Parameter) Init

func (o *Parameter) Init(data map[string]interface{})

type ResourceItem added in v0.1.3

type ResourceItem struct {
	Data []byte
	Mime string
}

type Variable

type Variable struct {
	Name       string
	Type       string
	InitialVal interface{}
	Value      interface{}
	Expression string
	ExecuteOn  string
}

func (*Variable) GetBool

func (o *Variable) GetBool(defValue ...bool) bool

func (*Variable) GetFloat

func (o *Variable) GetFloat(defValue ...float64) float64

func (*Variable) GetInt

func (o *Variable) GetInt(defValue ...int) int

func (*Variable) GetString

func (o *Variable) GetString(defValue ...string) string

func (*Variable) Init

func (o *Variable) Init(data map[string]interface{})

Jump to

Keyboard shortcuts

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