import "github.com/objectbox/objectbox-go/internal/generator"
Package generator provides tools to generate ObjectBox entity bindings between GO structs & ObjectBox schema
ast.go binding-property.go binding.go fields.go generator.go merge.go options.go
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
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 Binding struct { Package *types.Package Entities []*Entity Imports map[string]string // contains filtered or unexported fields }
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 }
called from the template avoid GO error "variable declared and not used"
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 }
called from the template
type Identifier struct { Id id Uid uid }
type Index struct { Identifier }
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 }
calculates flatbuffers slot number called from the template
calculates flatbuffers vTableOffset called from the template
returns full path to the property (in embedded struct) called from the template
type StandaloneRelation struct { Identifier Target struct { Identifier Name string IsPointer bool } Name string // contains filtered or unexported fields }
Path | Synopsis |
---|---|
modelinfo | |
templates |
Package generator imports 22 packages (graph) and is imported by 2 packages. Updated 2019-08-02. Refresh now. Tools for package owners.