model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2019 License: MIT Imports: 3 Imported by: 55

Documentation

Index

Constants

View Source
const (
	Kind_None      Kind = ""
	Kind_Primitive      = "primitive"
	Kind_Struct         = "struct"
	Kind_Enum           = "enum"
)

Variables

View Source
var SchemeType2Type = map[string]string{
	"int8":    "int8",
	"int16":   "int16",
	"int32":   "int32",
	"int64":   "int64",
	"uint8":   "uint8",
	"uint16":  "uint16",
	"uint32":  "uint32",
	"uint64":  "uint64",
	"float32": "float32",
	"float64": "float64",
	"bool":    "bool",
	"string":  "string",
	"bytes":   "bytes",
}

Functions

func TypeSize

func TypeSize(t string) int32

Types

type Comment

type Comment struct {
	// 头注释
	Leading string `json:",omitempty"`

	// 尾注释
	Trailing string `json:",omitempty"`
}

注释

type Descriptor

type Descriptor struct {
	Comment
	TagSet

	Name string

	// 枚举或结构体
	Kind Kind

	// 归属的文件名
	SrcName string

	// 字段集合
	Fields []*FieldDescriptor `json:",omitempty"`

	DescriptorSet *DescriptorSet `json:"-"`
}

结构体或枚举

func (*Descriptor) AddField

func (self *Descriptor) AddField(fd *FieldDescriptor)

func (*Descriptor) FieldByName

func (self *Descriptor) FieldByName(name string) *FieldDescriptor

func (*Descriptor) FieldNameExists

func (self *Descriptor) FieldNameExists(name string) bool

func (*Descriptor) FieldTagExists

func (self *Descriptor) FieldTagExists(tag int) bool

func (*Descriptor) Size

func (self *Descriptor) Size() (size int32)

type DescriptorSet

type DescriptorSet struct {
	Objects     []*Descriptor `json:",omitempty"`
	PackageName string
}

func (*DescriptorSet) AddObject

func (self *DescriptorSet) AddObject(d *Descriptor)

func (*DescriptorSet) Enums

func (self *DescriptorSet) Enums() (ret []*Descriptor)

func (*DescriptorSet) ObjectByName

func (self *DescriptorSet) ObjectByName(name string) *Descriptor

func (*DescriptorSet) ObjectNameExists

func (self *DescriptorSet) ObjectNameExists(name string) bool

func (*DescriptorSet) Structs

func (self *DescriptorSet) Structs() (ret []*Descriptor)

type FieldDescriptor

type FieldDescriptor struct {
	Comment
	TagSet

	Name string
	Type string

	Kind Kind // 原始类型/结构体/枚举

	Tag     int  `json:",omitempty"`
	Repeatd bool `json:",omitempty"`

	Descriptor *Descriptor `json:"-"`
}

func (*FieldDescriptor) ParseType

func (self *FieldDescriptor) ParseType(str string)

type Kind

type Kind string

type Tag

type Tag struct {
	Key   string
	Value string
}

标记

type TagSet

type TagSet struct {
	Tags []Tag `json:",omitempty"`
}

标记集合

func (*TagSet) AddTag

func (self *TagSet) AddTag(tag Tag)

func (*TagSet) SetTagValue

func (self *TagSet) SetTagValue(key, value string)

func (*TagSet) TagExists

func (self *TagSet) TagExists(key string) bool

func (*TagSet) TagValueBool

func (self *TagSet) TagValueBool(key string) bool

func (*TagSet) TagValueByKey

func (self *TagSet) TagValueByKey(key string) (string, bool)

func (*TagSet) TagValueInt

func (self *TagSet) TagValueInt(key string) int

func (*TagSet) TagValueString

func (self *TagSet) TagValueString(key string) string

Jump to

Keyboard shortcuts

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