generator

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2015 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StoreNamePattern     = "%sStore"
	QueryNamePattern     = "%sQuery"
	ResultSetNamePattern = "%sResultSet"
)
View Source
const BaseDocument = "github.com/tyba/storable.Document"

Variables

This section is empty.

Functions

func NewFunction

func NewFunction()

Types

type Field

type Field struct {
	Name        string
	Type        string
	CheckedNode *types.Var
	Tag         reflect.StructTag
	Fields      []*Field
	Parent      *Field

	Hooks []Hook
	// contains filtered or unexported fields
}

func NewField

func NewField(n, t string, tag reflect.StructTag) *Field

func (*Field) AddField

func (f *Field) AddField(field *Field)

func (*Field) ContainsMap

func (f *Field) ContainsMap() bool

func (*Field) DbName

func (f *Field) DbName() string

func (*Field) Findable

func (f *Field) Findable() bool

func (*Field) FindableType

func (f *Field) FindableType() string

func (*Field) GetPath

func (f *Field) GetPath() string

func (*Field) GetTagValue

func (f *Field) GetTagValue(key string) string

func (*Field) SetFields

func (f *Field) SetFields(sf []*Field)

func (*Field) String

func (f *Field) String() string

func (*Field) ValidFields

func (f *Field) ValidFields() []*Field

type Function

type Function struct {
	Name string
	Args string
}

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator(filename string) *Generator

func (*Generator) Generate

func (g *Generator) Generate(pkg *Package) error

type Hook added in v0.2.0

type Hook struct {
	Before bool
	Action HookAction
}

func (Hook) MethodName added in v0.2.0

func (h Hook) MethodName() string

type HookAction added in v0.2.0

type HookAction string
const (
	InsertHook HookAction = "Insert"
	UpdateHook HookAction = "Update"
	SaveHook   HookAction = "Save"
)

type Model

type Model struct {
	Name          string
	StoreName     string
	QueryName     string
	ResultSetName string

	Collection  string
	Type        string
	Fields      []*Field
	CheckedNode *types.Named
	NewFunc     *types.Func
	Package     *types.Package

	Hooks      []Hook
	StoreHooks []Hook
}

func NewModel

func NewModel(n string) *Model

func (*Model) NewArgVars

func (m *Model) NewArgVars() string

func (*Model) NewArgs

func (m *Model) NewArgs() string

func (*Model) NewRetVars

func (m *Model) NewRetVars() string

func (*Model) NewReturns

func (m *Model) NewReturns() string

func (*Model) String

func (m *Model) String() string

func (*Model) ValidFields

func (m *Model) ValidFields() []*Field

type Package

type Package struct {
	Name      string
	Models    []*Model
	Structs   []string
	Functions []string
}

func (*Package) FunctionIsDefined

func (p *Package) FunctionIsDefined(name string) bool

func (*Package) StructIsDefined

func (p *Package) StructIsDefined(name string) bool

type Processor

type Processor struct {
	Path   string
	Ignore map[string]bool

	TypesPkg *types.Package
}

func NewProcessor

func NewProcessor(path string, ignore []string) *Processor

func (*Processor) Do

func (p *Processor) Do() (*Package, error)

func (*Processor) ProcessTypesPkg added in v0.2.0

func (p *Processor) ProcessTypesPkg() (*Package, error)

type Template

type Template struct {
	// contains filtered or unexported fields
}
var Base *Template = &Template{template: base}

func (*Template) Execute

func (t *Template) Execute(wr io.Writer, data *Package) error

type TemplateData

type TemplateData struct {
	*Package
	Fields    []*TemplateField
	Processed map[interface{}]string
}

func (*TemplateData) CallHooks added in v0.2.0

func (td *TemplateData) CallHooks(whenStr, actionStr string, upsert bool, model *Model) string

func (*TemplateData) GenType

func (td *TemplateData) GenType(vi interface{}, path string) string

func (*TemplateData) GenVar

func (td *TemplateData) GenVar(vi interface{}, done map[interface{}]bool) string

func (*TemplateData) LinkStruct

func (td *TemplateData) LinkStruct(path string, vi interface{}) string

func (*TemplateData) StructValue

func (td *TemplateData) StructValue(vi interface{}, done map[interface{}]bool) string

type TemplateField

type TemplateField struct {
	Name   string
	Path   string
	Fields interface{}
}

func (*TemplateField) ValidFields

func (tf *TemplateField) ValidFields() []*Field

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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