conv

package
v0.0.0-...-adc1ce0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeEnum = iota
	TypeMessage
)

Variables

View Source
var (
	// https://developers.google.com/protocol-buffers/docs/proto3#scalar
	PbGoTypes = map[string]string{
		"double":   "float64",
		"float":    "float32",
		"int32":    "int32",
		"int64":    "int64",
		"uint32":   "uint32",
		"uint64":   "uint64",
		"sint32":   "int32",
		"sint64":   "int64",
		"fixed32":  "uint32",
		"fixed64":  "uint64",
		"sfixed32": "int32",
		"sfixed64": "int64",
		"bool":     "bool",
		"string":   "string",
		"bytes":    "[]byte",
	}
)

Functions

func BlockToA

func BlockToA(ident, name string, level int, content func(int) string) string

func EnumToA

func EnumToA(e *parser.Enum, level int) string

func FieldToA

func FieldToA(f *parser.Field, level int) string

func Indentation

func Indentation(level int) string

func LineOptionsToA

func LineOptionsToA(opts map[string]string) string

func LineToA

func LineToA(mod, typ, name, number string, opts map[string]string, level int) string

func MapToA

func MapToA(m *parser.MapField, level int) string

func MessageToA

func MessageToA(m *parser.Message, level int) string

func MessageToAction

func MessageToAction(m *parser.Message, level int) string

func MessageToFlag

func MessageToFlag(m *parser.Message, level int, prefix string, required bool) (string, error)

TODO change MessageToFlag > MessageToEntry

func MetaToAction

func MetaToAction(r *Resource, level int) string

func MetaToFlag

func MetaToFlag(r *Resource, level int) string

TODO change MetaToFlag > MetaToEntry

func OneofToA

func OneofToA(o *parser.Oneof, level int) string

func OperationsToA

func OperationsToA(name string, ops []string) string

func OptionToA

func OptionToA(o *parser.Option, level int) string

func PbToGoType

func PbToGoType(t string) string

func PrefixName

func PrefixName(prefix, name string) string

func ResourceToAction

func ResourceToAction(r *Resource, level int) string

func ResourceToFlag

func ResourceToFlag(r *Resource, level int) string

TODO change ResourceToFlag > ResourceToEntry

func WriteRune

func WriteRune(b *strings.Builder, r rune)

func WriteString

func WriteString(b *strings.Builder, s string)

Types

type Entry

type Entry struct {
	Name     string
	FlagName string
	Type     string
	Default  string
	Required bool
}

func EnumToEntry

func EnumToEntry(e *parser.Enum, level int, prefix string, required bool) *Entry

func FieldToEntry

func FieldToEntry(f *parser.Field, level int, prefix string, required bool) *Entry

func (*Entry) ToField

func (e *Entry) ToField(level int) string

func (*Entry) ToFlag

func (e *Entry) ToFlag(level int) string

type Proto

type Proto struct {
	Options  []*parser.Option
	Package  *parser.Package
	Services []*Service
	Messages []*parser.Message
	Syntax   *parser.Syntax
}

func NewProto

func NewProto() *Proto

func (*Proto) Resources

func (p *Proto) Resources() []*Resource

func (*Proto) String

func (p *Proto) String() string

type Resource

type Resource struct {
	Name       string
	Meta       *parser.Message
	Enums      []*parser.Enum
	Fields     []*parser.Field
	Maps       []*parser.MapField
	Messages   []*parser.Message
	Options    []*parser.Option
	Oneofs     []*parser.Oneof
	Operations []string
	Types      map[string]int
}

func (*Resource) MessageString

func (r *Resource) MessageString() string

func (*Resource) OperationString

func (r *Resource) OperationString() string

func (*Resource) SetOperations

func (r *Resource) SetOperations(o *parser.Option)

type ResourceEntries

type ResourceEntries struct {
	MetaEntries []*Entry
	Entries     []*Entry
}

type Service

type Service struct {
	Name      string
	Resources []*Resource
}

func (*Service) String

func (s *Service) String() string

Jump to

Keyboard shortcuts

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