generator

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package generator provides tools to generate ObjectBox entity bindings between GO structs & ObjectBox schema

Index

Constants

View Source
const Version = 2

Variables

This section is empty.

Functions

func BindingFile

func BindingFile(sourceFile string) string

func ModelFile

func ModelFile(modelInfoFile string) string

func ModelInfoFile

func ModelInfoFile(dir string) string

func Process

func Process(sourceFile string, options Options) error

Process is the main API method of the package it takes source file & model-information file paths and generates bindings (as a sibling file to the source file)

Types

type Annotation

type Annotation struct {
	Value string
}

type Binding

type Binding struct {
	Package  *types.Package
	Entities []*Entity
	Imports  map[string]string
	// contains filtered or unexported fields
}

type Entity

type Entity struct {
	Identifier
	Name           string
	Fields         []*Field // the tree of struct fields (necessary for embedded structs)
	Properties     []*Property
	IdProperty     *Property
	LastPropertyId modelinfo.IdUid
	Relations      map[string]*StandaloneRelation
	Annotations    map[string]*Annotation
	// contains filtered or unexported fields
}

func (*Entity) HasNonIdProperty

func (entity *Entity) HasNonIdProperty() bool

called from the template avoid GO error "variable declared and not used"

func (*Entity) HasRelations added in v0.9.0

func (entity *Entity) HasRelations() bool

type Field added in v0.9.0

type Field struct {
	Entity             *Entity // parent entity
	Name               string
	Type               string
	IsPointer          bool
	Property           *Property // nil if it's an embedded struct
	Fields             []*Field  // inner fields, nil if it's a property
	SimpleRelation     *Relation
	StandaloneRelation *StandaloneRelation
}

func (*Field) HasRelations added in v0.9.0

func (field *Field) HasRelations() bool

func (*Field) IsId added in v0.9.0

func (field *Field) IsId() bool

called from the template

type Identifier added in v0.9.0

type Identifier struct {
	Id  id
	Uid uid
}

type Index

type Index struct {
	Identifier
}

type Options added in v0.9.0

type Options struct {
	ModelInfoFile string
	ByValue       bool
}

type Property

type Property struct {
	Identifier
	BaseName    string // name in the containing struct (might be embedded)
	Name        string // prefixed name (unique)
	ObName      string // name of the field in DB
	Annotations map[string]*Annotation
	ObType      string
	ObFlags     []string
	GoType      string
	FbType      string
	Relation    *Relation
	Index       *Index
	Converter   *string

	// type casts for named types
	CastOnRead  string
	CastOnWrite string
	// contains filtered or unexported fields
}

func (*Property) FbSlot

func (property *Property) FbSlot() int

calculates flatbuffers slot number called from the template

func (*Property) FbvTableOffset

func (property *Property) FbvTableOffset() uint16

calculates flatbuffers vTableOffset called from the template

func (*Property) Path added in v0.9.0

func (property *Property) Path() string

returns full path to the property (in embedded struct) called from the template

type Relation

type Relation struct {
	Target struct {
		Name string
	}
}

type StandaloneRelation added in v0.9.0

type StandaloneRelation struct {
	Identifier
	Target struct {
		Identifier
		Name      string
		IsPointer bool
	}
	Name string
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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