generator

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2016 License: MIT Imports: 19 Imported by: 3

Documentation

Index

Constants

View Source
const (
	StoreNamePattern     = "%sStore"
	QueryNamePattern     = "%sQuery"
	ResultSetNamePattern = "%sResultSet"
)
View Source
const BaseDocument = "gopkg.in/src-d/storable.v1.Document"

Variables

View Source
var (
	ErrEventConflict = errors.New(
		"Event conflict a *Save and a *Update or *Insert are present",
	)
)

Functions

func NewFunction

func NewFunction()

Types

type Event

type Event string
const (
	BeforeInsert Event = "BeforeInsert"
	AfterInsert  Event = "AfterInsert"
	BeforeUpdate Event = "BeforeUpdate"
	AfterUpdate  Event = "AfterUpdate"
	BeforeSave   Event = "BeforeSave"
	AfterSave    Event = "AfterSave"
)

type Events

type Events []Event

func (Events) Has

func (s Events) Has(e Event) bool

type Field

type Field struct {
	Name        string
	Type        string
	CheckedNode *types.Var
	Tag         reflect.StructTag
	Fields      []*Field
	Parent      *Field
	// 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) Inline

func (f *Field) Inline() bool

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 Model

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

	Collection  string
	Type        string
	Fields      []*Field
	New         bool
	Init        bool
	Events      Events
	CheckedNode *types.Named
	NewFunc     *types.Func
	Package     *types.Package
}

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

func (*Model) Validate

func (m *Model) Validate() error

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
	SourceCode map[string][]byte
}

func NewProcessor

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

func (*Processor) Do

func (p *Processor) Do() (*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) 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