state

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnknownDirectionDirection = iota
	ParentToChild
	ChildToParent
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction uint

Direction is a type for how to generate json statements.

type MessageDescriptor

type MessageDescriptor struct {
	Descriptor    *descriptor.DescriptorProto
	StructureName string
	SourceName    string
}

MessageDescriptor is a descriptor for a message.

type Messages

type Messages []*descriptorpb.DescriptorProto

Messages is a type for how to generate json statements.

func (Messages) FindByName

func (t Messages) FindByName(name string) *descriptorpb.DescriptorProto

FindByName returns the table with the given name.

func (Messages) String

func (t Messages) String() string

String returns a string representation of the Messages.

type NestedMessages

type NestedMessages map[string]*MessageDescriptor

NestedMessages is a type for how to generate json statements.

func (NestedMessages) CheckIsRelation

func (t NestedMessages) CheckIsRelation(f *descriptorpb.FieldDescriptorProto) bool

CheckIsRelation checks if the given field is a Relation.

func (NestedMessages) Get

Get gets the table by the given name.

func (NestedMessages) GetByField

GetByField returns the table by the given field.

func (NestedMessages) GetByFieldDescriptor

GetByFieldDescriptor gets the table by the given descriptor.

func (NestedMessages) GetDescriptor

func (t NestedMessages) GetDescriptor(name string) (*descriptorpb.DescriptorProto, bool)

GetDescriptor returns the table with the given name.

func (NestedMessages) IsExist

IsExist checks if the given name exists in the Messages.

func (NestedMessages) IsJSON

IsJSON returns true if the field is a JSON field.

func (NestedMessages) String

func (t NestedMessages) String() string

String returns a string representation of the NestedMessages.

type NestedTableVal

type NestedTableVal struct {
	StructureName string
	HasType       bool
}

NestedTableVal is a type for how to generate json statements.

type Relation

type Relation struct {
	RelationDescriptor *descriptor.DescriptorProto
	ParentDescriptor   *descriptor.DescriptorProto
	Descriptor         *descriptor.FieldDescriptorProto
	Field              string
	Direction          Direction
	Reference          string
	TableName          string
	StructName         string
	Store              string
	Many               bool
	AllowSubCreating   bool
	UseTag             bool
}

Relation is a type for how to generate json statements.

type RelationType

type RelationType string

RelationType is a type for how to generate json statements.

func NewRelationType

func NewRelationType(messageName string, structureName string) RelationType

NewRelationType creates a new relation type.

func (RelationType) String

func (r RelationType) String() string

Relation SingleTypes.

type Relations

type Relations map[RelationType]*Relation

Relations is a type for how to generate json statements.

func (Relations) Delete

func (r Relations) Delete(name string)

Delete deletes the Relation by the given name.

func (Relations) Find added in v1.0.10

func (r Relations) Find(name string) (*Relation, bool)

func (Relations) FindBy added in v1.0.10

func (Relations) FindByMessage added in v1.0.13

func (Relations) Get

func (r Relations) Get(name string) (*Relation, bool)

Get returns the Relation by the given name.

func (Relations) GetByFieldDescriptor

func (r Relations) GetByFieldDescriptor(f *descriptorpb.FieldDescriptorProto) *Relation

GetByFieldDescriptor returns the Relation by the given FieldDescriptorProto.

func (Relations) IsExist

IsExist checks if the given name exists in the Messages.

func (Relations) String

func (r Relations) String() string

String returns a string representation of the Relations.

type SingleType

type SingleType struct {
	ParentDescriptor *descriptor.DescriptorProto
	Descriptor       *descriptor.FieldDescriptorProto

	ParentStructureName string
	FieldName           string
	FieldType           string
	SourceType          string
	SourceName          string
	StructureName       string
	Repeated            bool
}

SingleType is a type for how to generate json statements.

type SingleTypes

type SingleTypes map[string]SingleType

SingleTypes is a type for how to generate json statements.

func (SingleTypes) Delete

func (j SingleTypes) Delete(name string)

Delete deletes the SingleType by the given name.

func (SingleTypes) ExistByName

func (j SingleTypes) ExistByName(name string) bool

ExistByName checks if the given name exists in the Messages.

func (SingleTypes) Get

func (j SingleTypes) Get(name string) (SingleType, bool)

Get returns the SingleType by the given name.

func (SingleTypes) GetByFieldDescriptor

func (j SingleTypes) GetByFieldDescriptor(f *descriptorpb.FieldDescriptorProto) *SingleType

GetByFieldDescriptor returns the SingleType by the given FieldDescriptorProto.

func (SingleTypes) GetByName

func (j SingleTypes) GetByName(name string) *SingleType

GetByName returns the SingleType by the given name.

func (SingleTypes) IsExist

IsExist checks if the given name exists in the Messages.

func (SingleTypes) String

func (j SingleTypes) String() string

String returns a string representation of the SingleTypes.

type State

type State struct {
	Provider          string // Provider is the Provider of the plugin.
	PackageName       string // PackageName is the package name of the plugin.
	FileName          string // FileName is the file name of the plugin.
	Version           string // Version is the Version of the plugin.
	ProtocVersion     string // ProtocVersion is the Version of protoc.
	FileToGenerate    string // FileToGenerate is the file to generate.
	IncludeConnection bool   // IncludeConnection is the flag to include connection in the generated code.

	Imports        importpkg.ImportSet // Imports is the set of Imports.
	Relations      Relations           // Relations is the set of Relations Messages.
	Messages       Messages            // Messages is the set of root Messages.
	NestedMessages NestedMessages      // NestedMessages is the set of nested Messages.

	// SingleTypes is the set of single types. example: type UserNames []string
	// used for generating json statements.
	SingleTypes SingleTypes
}

State is the state of the plugin.

func NewState

func NewState(
	request *plugingo.CodeGeneratorRequest,
) *State

NewState returns a new State.

func (*State) ImportsFromTable

func (s *State) ImportsFromTable(tables []Templater)

ImportsFromTable Imports the given table.

func (*State) IsExistInNestedTables

func (s *State) IsExistInNestedTables(name string) bool

IsExistInNestedTables checks if the given name exists in the nested Messages.

func (*State) IsExistInTables

func (s *State) IsExistInTables(name string) bool

IsExistInTables checks if the given name exists in the Messages.

func (*State) IsRelation added in v1.0.3

func (s *State) IsRelation(f *descriptorpb.FieldDescriptorProto) bool

IsRelation checks if the given field is a Relation.

func (*State) String

func (s *State) String() string

String returns a string representation of the State.

type Templater

type Templater interface {
	TemplateName() string
	BuildTemplate() string
	Imports() importpkg.ImportSet
}

Templater is an interface for generating templates.

Jump to

Keyboard shortcuts

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