Documentation
¶
Index ¶
- func MarshalText(data uint32, set map[uint32]string) ([]byte, error)
- func ReadBinarySchema(path string, bb *ByteBuffer) error
- func UnmarshalText(bytes []byte, set map[string]uint32) (uint32, error)
- type BinarySchema
- type ByteBuffer
- func (bb *ByteBuffer) Bytes() []byte
- func (bb *ByteBuffer) OriginRead(value []byte) (n int, err error)
- func (bb *ByteBuffer) OriginReadByte() (b byte, err error)
- func (bb *ByteBuffer) OriginReadBytes(delim byte) (line []byte, err error)
- func (bb *ByteBuffer) OriginReadRune() (r rune, size int, err error)
- func (bb *ByteBuffer) OriginReadString(delim byte) (line string, err error)
- func (bb *ByteBuffer) OriginWrite(value []byte) (n int, err error)
- func (bb *ByteBuffer) OriginWriteByte(value byte) (err error)
- func (bb *ByteBuffer) OriginWriteRune(value rune) (n int, err error)
- func (bb *ByteBuffer) OriginWriteString(value string) (n int, err error)
- func (bb *ByteBuffer) ReadByteB(result *bool) bool
- func (bb *ByteBuffer) ReadByteC(result *byte) bool
- func (bb *ByteBuffer) ReadString(result *string) bool
- func (bb *ByteBuffer) ReadVarFloat(result *float32) bool
- func (bb *ByteBuffer) ReadVarInt(result *int32) bool
- func (bb *ByteBuffer) ReadVarUint(result *uint32) bool
- func (bb *ByteBuffer) Reset()
- func (bb *ByteBuffer) WriteByteB(value bool)
- func (bb *ByteBuffer) WriteByteC(value byte)
- func (bb *ByteBuffer) WriteString(value string)
- func (bb *ByteBuffer) WriteVarFloat(value float32)
- func (bb *ByteBuffer) WriteVarInt(value int32)
- func (bb *ByteBuffer) WriteVarUint(value uint32)
- type Definition
- type Field
- type SchemaKind
- type SchemaType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalText ¶
MarshalText Marshall 实现 Deprecated: Marshal should use String instead (or additionally).
func ReadBinarySchema ¶
func ReadBinarySchema(path string, bb *ByteBuffer) error
ReadBinarySchema 读取 .bkiwi 文件
Types ¶
type BinarySchema ¶
type BinarySchema struct {
// contains filtered or unexported fields
}
BinarySchema parsed from binary kiwi file
func (*BinarySchema) FindDefinition ¶
func (bs *BinarySchema) FindDefinition(definition string, index *uint32) bool
FindDefinition find if the given definition is exist.
func (*BinarySchema) Parse ¶
func (bs *BinarySchema) Parse(bb *ByteBuffer) bool
Parse parse a binary kiwi file from buffer
func (*BinarySchema) SkipField ¶
func (bs *BinarySchema) SkipField(bb *ByteBuffer, definition uint32, field uint32) bool
SkipField check whether the field should be skipped.
type ByteBuffer ¶
type ByteBuffer struct {
// contains filtered or unexported fields
}
ByteBuffer a wrapper of bytes.Buffer for more Origin Function of bytes.Buffer, see origin_wrapper.go
func NewByteBuffer ¶ added in v1.0.1
func NewByteBuffer(buf []byte) *ByteBuffer
NewByteBuffer new a ByteBuffer with a customized buffer. use new(ByteBuffer) instead, with a default blank buffer.
func (*ByteBuffer) Bytes ¶ added in v1.0.4
func (bb *ByteBuffer) Bytes() []byte
Bytes get bytes data
func (*ByteBuffer) OriginRead ¶ added in v1.0.4
func (bb *ByteBuffer) OriginRead(value []byte) (n int, err error)
OriginRead bytes.Buffer.Read
func (*ByteBuffer) OriginReadByte ¶ added in v1.0.4
func (bb *ByteBuffer) OriginReadByte() (b byte, err error)
OriginReadByte bytes.Buffer.ReadByte
func (*ByteBuffer) OriginReadBytes ¶ added in v1.0.4
func (bb *ByteBuffer) OriginReadBytes(delim byte) (line []byte, err error)
OriginReadBytes bytes.Buffer.ReadBytes
func (*ByteBuffer) OriginReadRune ¶ added in v1.0.4
func (bb *ByteBuffer) OriginReadRune() (r rune, size int, err error)
OriginReadRune bytes.Buffer.ReadRune
func (*ByteBuffer) OriginReadString ¶ added in v1.0.4
func (bb *ByteBuffer) OriginReadString(delim byte) (line string, err error)
OriginReadString bytes.Buffer.ReadString
func (*ByteBuffer) OriginWrite ¶ added in v1.0.4
func (bb *ByteBuffer) OriginWrite(value []byte) (n int, err error)
OriginWrite bytes.Buffer.Write
func (*ByteBuffer) OriginWriteByte ¶ added in v1.0.4
func (bb *ByteBuffer) OriginWriteByte(value byte) (err error)
OriginWriteByte bytes.Buffer.WriteByte
func (*ByteBuffer) OriginWriteRune ¶ added in v1.0.4
func (bb *ByteBuffer) OriginWriteRune(value rune) (n int, err error)
OriginWriteRune bytes.Buffer.WriteRune
func (*ByteBuffer) OriginWriteString ¶ added in v1.0.4
func (bb *ByteBuffer) OriginWriteString(value string) (n int, err error)
OriginWriteString bytes.Buffer.WriteString
func (*ByteBuffer) ReadByteB ¶
func (bb *ByteBuffer) ReadByteB(result *bool) bool
ReadByteB read single byte of type bool
func (*ByteBuffer) ReadByteC ¶
func (bb *ByteBuffer) ReadByteC(result *byte) bool
ReadByteC read single byte of type byte
func (*ByteBuffer) ReadString ¶
func (bb *ByteBuffer) ReadString(result *string) bool
ReadString read string data with \x00 tail
func (*ByteBuffer) ReadVarFloat ¶
func (bb *ByteBuffer) ReadVarFloat(result *float32) bool
ReadVarFloat read float32 data with VarFloat encode
func (*ByteBuffer) ReadVarInt ¶
func (bb *ByteBuffer) ReadVarInt(result *int32) bool
ReadVarInt read int32 data with VarInts encode
func (*ByteBuffer) ReadVarUint ¶
func (bb *ByteBuffer) ReadVarUint(result *uint32) bool
ReadVarUint read uint32 data with VarInts encode
func (*ByteBuffer) WriteByteB ¶
func (bb *ByteBuffer) WriteByteB(value bool)
WriteByteB write single byte of type bool
func (*ByteBuffer) WriteByteC ¶
func (bb *ByteBuffer) WriteByteC(value byte)
WriteByteC write single byte of type byte
func (*ByteBuffer) WriteString ¶
func (bb *ByteBuffer) WriteString(value string)
WriteString write string data with \x00 tail
func (*ByteBuffer) WriteVarFloat ¶
func (bb *ByteBuffer) WriteVarFloat(value float32)
WriteVarFloat write float32 data with VarFloat encode
func (*ByteBuffer) WriteVarInt ¶
func (bb *ByteBuffer) WriteVarInt(value int32)
WriteVarInt write int32 data with VarInts encode
func (*ByteBuffer) WriteVarUint ¶
func (bb *ByteBuffer) WriteVarUint(value uint32)
WriteVarUint write uint32 data with VarInts encode
type Definition ¶
type Definition struct {
// contains filtered or unexported fields
}
Definition description of schema structure
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field description of schema field
type SchemaKind ¶
type SchemaKind uint8
SchemaKind definition kind in kiwi
const ( //Enum Uint32 with a restricted set of values that are identified by name. //New fields can be added to any MESSAGE while maintaining backwards compatibility. Enum SchemaKind = 0 //Struct Compound value with a fixed set of fields that are always required and written out in order. //New fields cannot be added to a struct once that struct is in use. Struct SchemaKind = 1 //Message Compound value with optional fields. //New fields can be added to any message while maintaining backwards compatibility. Message SchemaKind = 2 )
type SchemaType ¶
type SchemaType int32
SchemaType filed type in kiwi
const ( //Bool bool Bool SchemaType = -1 //Byte byte Byte SchemaType = -2 //Int int32 Int SchemaType = -3 //Uint uint32 Uint SchemaType = -4 //Float float32 Float SchemaType = -5 //String string String SchemaType = -6 )