protobuff_v3

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEnum

func AddEnum(enum *Enum)

func AddMessage

func AddMessage(message *Message)

func GetMapper

func GetMapper() *mapper

func InitCache

func InitCache()

func NewMapper

func NewMapper(schema *schema.OCSFSchema) *mapper

func NewProto

func NewProto(p *Pkg)

func ToEnumName

func ToEnumName(input string) string

ToEnumName converts a string to a valid Enum Name

func ToEnumValueName

func ToEnumValueName(input string) string

func ToMessageName

func ToMessageName(input string) string

Types

type CacheMap

type CacheMap struct {
	Messages   commons.Cache
	Enums      commons.Cache
	EnumValues commons.Cache
}

func Cache

func Cache() *CacheMap

type Comment

type Comment map[string]string

type Enum

type Enum struct {
	Name string

	Package *Pkg
	// contains filtered or unexported fields
}

func GetEnum

func GetEnum(name string) (*Enum, bool)

func (*Enum) AddValue

func (e *Enum) AddValue(value *EnumValue)

Enum represents a Protobuf Enum

func (*Enum) GetName

func (e *Enum) GetName() string

GetName returns the name of the Enum

func (*Enum) GetPackage

func (e *Enum) GetPackage() string

GetPackage returns the package name of the Enum

func (*Enum) GetReference

func (e *Enum) GetReference() string

GetReference returns the reference of the Enum

func (*Enum) GetValue

func (e *Enum) GetValue(name string) (*EnumValue, bool)

Enum represents a Protobuf Enum

func (*Enum) GetValues added in v0.1.5

func (e *Enum) GetValues() []*EnumValue

Get enum values sorted by name (with UNKNOWN coming first)

func (*Enum) HasUnknown added in v0.1.5

func (e *Enum) HasUnknown() bool

Enum has at least one value ending with UNKNOWN

func (*Enum) Marshal

func (e *Enum) Marshal() string

Marshal returns the Enum as a string

type EnumValue

type EnumValue struct {
	Name    string  `json:"name"`
	Value   int64   `json:"value"`
	Comment Comment `json:",omitempty"`
	// contains filtered or unexported fields
}

func (*EnumValue) Marshal

func (ev *EnumValue) Marshal(index int) string

type EnumValues

type EnumValues map[string]*EnumValue

type Enums

type Enums map[string]*Enum

type Field

type Field struct {
	Name     string
	DataType string
	Required bool
	Repeated bool
	Map      bool
	Type     FieldType

	Comment Comment
	// contains filtered or unexported fields
}

func (*Field) Marshal

func (f *Field) Marshal(index int) string

type FieldType

type FieldType int16
const (
	FIELD_TYPE_OBJECT    FieldType = 100
	FIELD_TYPE_PRIMITIVE FieldType = 110
	FIELD_TYPE_ENUM      FieldType = 120
)

type Fields

type Fields []*Field

type Import

type Import struct {
	Name string
}

func (*Import) Marshal

func (i *Import) Marshal() string

type Imports

type Imports map[string]*Import

type Message

type Message struct {
	Name string

	GroupKey string
	Comment  Comment
	Package  *Pkg
	// contains filtered or unexported fields
}

func GetMessage

func GetMessage(name string) (*Message, bool)

func (*Message) AddField

func (m *Message) AddField(field *Field)

func (*Message) GetImports

func (m *Message) GetImports() Imports

func (*Message) GetName

func (m *Message) GetName() string

func (*Message) GetPackage

func (m *Message) GetPackage() string

func (*Message) GetReference

func (m *Message) GetReference() string

func (*Message) Marshal

func (m *Message) Marshal() string

type Messages

type Messages map[string]*Message

type Pkg

type Pkg struct {
	Name     string
	Children Pkgs
	Parent   *Pkg
	Proto    *Proto
	Path     string
}

func NewPackage

func NewPackage(name string, parent *Pkg) *Pkg

func (*Pkg) GetDirName

func (p *Pkg) GetDirName() string

func (*Pkg) GetDirPath

func (p *Pkg) GetDirPath() string

func (*Pkg) GetEnums

func (p *Pkg) GetEnums() []*Enum

func (*Pkg) GetFullName

func (p *Pkg) GetFullName() string

func (*Pkg) GetMessages

func (p *Pkg) GetMessages() []*Message

func (*Pkg) GetName

func (p *Pkg) GetName() string

func (*Pkg) GetParentHierarchy

func (p *Pkg) GetParentHierarchy() []*Pkg

func (*Pkg) Marshal

func (p *Pkg) Marshal()

func (*Pkg) NewPackage

func (p *Pkg) NewPackage(pkgName string) *Pkg

type Pkgs

type Pkgs map[string]*Pkg

type Preprocessor

type Preprocessor struct {
	MessageName       func(string) string
	EnumName          func(string) string
	EnumValueName     func(string) string
	GolangPackageName func(string) string
	JavaPackageName   func(string) string
}

type Proto

type Proto struct {
	Pkg *Pkg
}

func (*Proto) GetProtoFilePath

func (p *Proto) GetProtoFilePath() string

func (*Proto) Marshal

func (p *Proto) Marshal()

type ProtoFile

type ProtoFile []string

Jump to

Keyboard shortcuts

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