Documentation
¶
Index ¶
- Constants
- type Direction
- type MessageDescriptor
- type Messages
- type NestedMessages
- func (t NestedMessages) CheckIsRelation(f *descriptorpb.FieldDescriptorProto) bool
- func (t NestedMessages) Get(name string) *MessageDescriptor
- func (t NestedMessages) GetByField(f *descriptorpb.FieldDescriptorProto) *MessageDescriptor
- func (t NestedMessages) GetByFieldDescriptor(f *descriptorpb.FieldDescriptorProto) *MessageDescriptor
- func (t NestedMessages) GetDescriptor(name string) (*descriptorpb.DescriptorProto, bool)
- func (t NestedMessages) IsExist(f *descriptorpb.FieldDescriptorProto) bool
- func (t NestedMessages) IsJSON(f *descriptorpb.FieldDescriptorProto) bool
- func (t NestedMessages) String() string
- type NestedTableVal
- type Relation
- type RelationType
- type Relations
- func (r Relations) Delete(name string)
- func (r Relations) Find(name string) (*Relation, bool)
- func (r Relations) FindBy(f *descriptorpb.FieldDescriptorProto) bool
- func (r Relations) FindByMessage(message *descriptorpb.DescriptorProto, f *descriptorpb.FieldDescriptorProto) bool
- func (r Relations) Get(name string) (*Relation, bool)
- func (r Relations) GetByFieldDescriptor(f *descriptorpb.FieldDescriptorProto) *Relation
- func (r Relations) IsExist(f *descriptorpb.FieldDescriptorProto) bool
- func (r Relations) String() string
- type SingleType
- type SingleTypes
- func (j SingleTypes) Delete(name string)
- func (j SingleTypes) ExistByName(name string) bool
- func (j SingleTypes) Get(name string) (SingleType, bool)
- func (j SingleTypes) GetByFieldDescriptor(f *descriptorpb.FieldDescriptorProto) *SingleType
- func (j SingleTypes) GetByName(name string) *SingleType
- func (j SingleTypes) IsExist(f *descriptorpb.FieldDescriptorProto) bool
- func (j SingleTypes) String() string
- type State
- type Templater
Constants ¶
const ( UnknownDirectionDirection = iota ParentToChild ChildToParent )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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.
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 ¶
func (t NestedMessages) Get(name string) *MessageDescriptor
Get gets the table by the given name.
func (NestedMessages) GetByField ¶
func (t NestedMessages) GetByField(f *descriptorpb.FieldDescriptorProto) *MessageDescriptor
GetByField returns the table by the given field.
func (NestedMessages) GetByFieldDescriptor ¶
func (t NestedMessages) GetByFieldDescriptor(f *descriptorpb.FieldDescriptorProto) *MessageDescriptor
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 ¶
func (t NestedMessages) IsExist(f *descriptorpb.FieldDescriptorProto) bool
IsExist checks if the given name exists in the Messages.
func (NestedMessages) IsJSON ¶
func (t NestedMessages) IsJSON(f *descriptorpb.FieldDescriptorProto) bool
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 ¶
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.
type Relations ¶
type Relations map[RelationType]*Relation
Relations is a type for how to generate json statements.
func (Relations) FindBy ¶ added in v1.0.10
func (r Relations) FindBy(f *descriptorpb.FieldDescriptorProto) bool
func (Relations) FindByMessage ¶ added in v1.0.13
func (r Relations) FindByMessage(message *descriptorpb.DescriptorProto, f *descriptorpb.FieldDescriptorProto) bool
func (Relations) GetByFieldDescriptor ¶
func (r Relations) GetByFieldDescriptor(f *descriptorpb.FieldDescriptorProto) *Relation
GetByFieldDescriptor returns the Relation by the given FieldDescriptorProto.
func (Relations) IsExist ¶
func (r Relations) IsExist(f *descriptorpb.FieldDescriptorProto) bool
IsExist checks if the given name exists in the Messages.
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 ¶
func (j SingleTypes) IsExist(f *descriptorpb.FieldDescriptorProto) bool
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 ¶
ImportsFromTable Imports the given table.
func (*State) IsExistInNestedTables ¶
IsExistInNestedTables checks if the given name exists in the nested Messages.
func (*State) IsExistInTables ¶
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.