objectbox-go: github.com/objectbox/objectbox-go/internal/generator Index | Files | Directories

package generator

import "github.com/objectbox/objectbox-go/internal/generator"

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

Index

Package Files

ast.go binding-property.go binding.go fields.go generator.go merge.go options.go

Constants

const (
    /// One long property on an entity must be the ID
    PropertyFlagId = 1

    /// On languages like Java, a non-primitive type is used (aka wrapper types, allowing null)
    PropertyFlagNonPrimitiveType = 2

    /// Unused yet
    PropertyFlagNotNull = 4

    PropertyFlagIndexed = 8

    PropertyFlagReserved = 16

    /// Unused yet: Unique index
    PropertyFlagUnique = 32

    /// Unused yet: Use a persisted sequence to enforce ID to rise monotonic (no ID reuse)
    PropertyFlaIdMonotonicSequence = 64

    /// Allow IDs to be assigned by the developer
    PropertyFlagIdSelfAssignable = 128

    /// Unused yet
    PropertyFlagIndexPartialSkipNull = 256

    /// Unused yet, used by References for 1) back-references and 2) to clear references to deleted objects (required for ID reuse)
    PropertyFlagIndexPartialSkipZero = 512

    /// Virtual properties may not have a dedicated field in their entity class, e.g. target IDs of to-one relations
    PropertyFlagVirtual = 1024

    /// Index uses a 32 bit hash instead of the value
    /// (32 bits is shorter on disk, runs well on 32 bit systems, and should be OK even with a few collisions)
    PropertyFlagIndexHash = 2048

    /// Index uses a 64 bit hash instead of the value
    /// (recommended mostly for 64 bit machines with values longer >200 bytes; small values are faster with a 32 bit hash)
    PropertyFlagIndexHash64 = 4096

    /// The actual type of the variable is unsigned (used in combination with numeric OBXPropertyType_*)
    PropertyFlagUnsigned = 8192
)
const (
    PropertyTypeBool         = 1
    PropertyTypeByte         = 2
    PropertyTypeShort        = 3
    PropertyTypeChar         = 4
    PropertyTypeInt          = 5
    PropertyTypeLong         = 6
    PropertyTypeFloat        = 7
    PropertyTypeDouble       = 8
    PropertyTypeString       = 9
    PropertyTypeDate         = 10
    PropertyTypeRelation     = 11
    PropertyTypeByteVector   = 23
    PropertyTypeStringVector = 30
)
const Version = 3

func BindingFile Uses

func BindingFile(sourceFile string) string

func ModelFile Uses

func ModelFile(modelInfoFile string) string

func ModelInfoFile Uses

func ModelInfoFile(dir string) string

func Process Uses

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)

type Annotation Uses

type Annotation struct {
    Value string
}

type Binding Uses

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

type Entity Uses

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) HasLazyLoadedRelations Uses

func (entity *Entity) HasLazyLoadedRelations() bool

func (*Entity) HasNonIdProperty Uses

func (entity *Entity) HasNonIdProperty() bool

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

func (*Entity) HasRelations Uses

func (entity *Entity) HasRelations() bool

type Field Uses

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 // to-many relation stored as a standalone relation in the model
    IsLazyLoaded       bool                // only standalone (to-many) relations currently support lazy loading
}

func (*Field) HasLazyLoadedRelations Uses

func (field *Field) HasLazyLoadedRelations() bool

func (*Field) HasRelations Uses

func (field *Field) HasRelations() bool

func (*Field) IsId Uses

func (field *Field) IsId() bool

called from the template

type Identifier Uses

type Identifier struct {
    Id  id
    Uid uid
}

type Index Uses

type Index struct {
    Identifier
}

type Options Uses

type Options struct {
    ModelInfoFile string
    ByValue       bool
    Rand          *rand.Rand
}

type Property Uses

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      int
    ObFlags     []int
    GoType      string
    FbType      string
    IsPointer   bool
    Relation    *Relation
    Index       *Index
    Converter   *string

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

func (*Property) FbSlot Uses

func (property *Property) FbSlot() int

calculates flatbuffers slot number called from the template

func (*Property) FbvTableOffset Uses

func (property *Property) FbvTableOffset() uint16

calculates flatbuffers vTableOffset called from the template

func (*Property) ObFlagsCombined Uses

func (property *Property) ObFlagsCombined() int

func (*Property) ObTypeString Uses

func (property *Property) ObTypeString() string

func (*Property) Path Uses

func (property *Property) Path() string

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

type Relation Uses

type Relation struct {
    Target struct {
        Name string
    }
}

type StandaloneRelation Uses

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

Directories

PathSynopsis
modelinfo
templates

Package generator imports 22 packages (graph) and is imported by 2 packages. Updated 2019-08-02. Refresh now. Tools for package owners.