Documentation ¶
Index ¶
- Constants
- Variables
- func TypeSize(t string) int32
- type Comment
- type Descriptor
- type DescriptorSet
- type FieldDescriptor
- type Kind
- type Tag
- type TagSet
- func (self *TagSet) AddTag(tag Tag)
- func (self *TagSet) SetTagValue(key, value string)
- func (self *TagSet) TagExists(key string) bool
- func (self *TagSet) TagValueBool(key string) bool
- func (self *TagSet) TagValueByKey(key string) (string, bool)
- func (self *TagSet) TagValueInt(key string) int
- func (self *TagSet) TagValueString(key string) string
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 ¶
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 TagSet ¶
type TagSet struct {
Tags []Tag `json:",omitempty"`
}
标记集合
func (*TagSet) SetTagValue ¶
func (*TagSet) TagValueBool ¶
func (*TagSet) TagValueInt ¶
func (*TagSet) TagValueString ¶
Click to show internal directories.
Click to hide internal directories.