Documentation ¶
Index ¶
- Constants
- Variables
- func MarshalBool(b bool) []byte
- func MarshalBools(bs []bool) []byte
- func MarshalByte(val int) []byte
- func MarshalBytes(vals []int) []byte
- func MarshalChar(val rune) []byte
- func MarshalChars(vals []rune) []byte
- func MarshalDict(dict Dict) []byte
- func MarshalDouble(val float64) []byte
- func MarshalDoubles(vals []float64) []byte
- func MarshalFloat(val float32) []byte
- func MarshalFloats(vals []float32) []byte
- func MarshalInt(val int) []byte
- func MarshalInts(vals []int) []byte
- func MarshalList(list List) []byte
- func MarshalLong(val int) []byte
- func MarshalLongs(vals []int) []byte
- func MarshalNull() []byte
- func MarshalObj(obj *Obj) []byte
- func MarshalSByte(val int) []byte
- func MarshalSBytes(vals []int) []byte
- func MarshalShort(val int) []byte
- func MarshalShorts(vals []int) []byte
- func MarshalStr16(str string) []byte
- func MarshalStr8(str string) []byte
- func MarshalStrings(vals []string) []byte
- func MarshalUInt(val int) []byte
- func MarshalUInts(vals []int) []byte
- func MarshalULong(val uint64) []byte
- func MarshalULongs(vals []uint64) []byte
- func MarshalUShort(val int) []byte
- func MarshalUShorts(vals []int) []byte
- func Unmarshal(src []byte) (interface{}, int, error)
- func UnmarshalAs(src []byte, types ...Type) (interface{}, int, error)
- type Dict
- type List
- type Obj
- type Type
Constants ¶
const ( SByteDataSize = 1 ByteDataSize = 1 CharDataSize = 2 ShortDataSize = 2 UShortDataSize = 2 IntDataSize = 4 UIntDataSize = 4 LongDataSize = 8 ULongDataSize = 8 FloatDataSize = 4 DoubleDataSize = 8 )
Variables ¶
var NumListElementType = map[Type]Type{ TypeSBytes: TypeSByte, TypeBytes: TypeByte, TypeChars: TypeChar, TypeShorts: TypeShort, TypeUShorts: TypeUShort, TypeInts: TypeInt, TypeUInts: TypeUInt, TypeLongs: TypeLong, TypeULongs: TypeULong, TypeFloats: TypeFloat, TypeDoubles: TypeDouble, }
var NumTypeDataSize = map[Type]int{ TypeSByte: SByteDataSize, TypeByte: ByteDataSize, TypeChar: CharDataSize, TypeShort: ShortDataSize, TypeUShort: UShortDataSize, TypeInt: IntDataSize, TypeUInt: UIntDataSize, TypeLong: LongDataSize, TypeULong: ULongDataSize, TypeFloat: FloatDataSize, TypeDouble: DoubleDataSize, }
Functions ¶
func MarshalChar ¶
MarshalChar marshals 16bit code-point.
if the val is larger than \uffff, it is replaced to \uffff.
func MarshalChars ¶
MarshalChars marshals 16bit code-point array format:
- TypeChars
- 16bit count
- repeat: 16bit BE integer...
func MarshalDict ¶
MarshalDict marshals Dict format:
- TypeDict
- 8bit count
- repeat:
- 8bit key length
- key string
- 16bit body length
- marshaled body
func MarshalDouble ¶
MarshalFloat marshals IEEE 754 double value as comparably.
func MarshalDoubles ¶
MarshalDoubles marshals IEEE754 single array
func MarshalFloat ¶
MarshalFloat marshals IEEE 754 single value as comparably. The sign-bit (MSB) is inverted to make the positive value greater than the negative value. All exponent and fraction bits on the negative value are inverted to make it natural order.
func MarshalFloats ¶
MarshalFloats marshals IEEE754 single array
func MarshalInt ¶
MarshalInt marshals signed 32bit integer comparably
func MarshalInts ¶
MarshalInts marshals signed 32bit integer array format:
- TypeInts
- 16bit count
- repeat: 32bit BE integer...
func MarshalList ¶
MarshalList marshals List format:
- TypeList
- 8bit count
- repeat:
- 16bit body length
- marshaled body
func MarshalLong ¶
MarshalLong marshals signed 64bit integer comparably
func MarshalLongs ¶
MarshalLongs marshals signed 64bit integer array format:
- TypeInts
- 16bit count
- repeat: 64bit BE integer...
func MarshalObj ¶
MarshalObj marshals Obj format:
- TypeObj
- 8bit class id (specified by app)
- 16bit body length
- body
func MarshalSByte ¶
MarshalSByte marshals signed 8bit integer comparably
This func maps the value -128..127 to unsigned value 0..255 to make the dst array comparable byte-by-byte directly.
func MarshalSBytes ¶
MarshalSBytes marshals sbytes array format:
- TypeSBytes
- 16bit count
- repeat: sbyte...
func MarshalShort ¶
MarshalUShort marshals signed 16bit integer comparably
func MarshalShorts ¶
MarshalShorts marshals signed 16bit integer array format:
- TypeShorts
- 16bit count
- repeat: 16bit BE integer...
func MarshalStr16 ¶
MarshalStr16 marshals long string (len > 255..65545)
func MarshalStr8 ¶
MarshalStr8 marshals short string (len <= 255)
func MarshalStrings ¶
func MarshalUInts ¶
MarshalInts marshals unsigned 32bit integer array format:
- TypeUInts
- 16bit count
- repeat: 32bit BE integer...
func MarshalULong ¶
MarshalULong marshals unsigned 64bit integer
func MarshalULongs ¶
MarshalULongs marshals unsigned 64bit integer array format:
- TypeInts
- 16bit count
- repeat: 64bit BE integer...
func MarshalUShort ¶
MarshalUShort marshals unsigned 16bit integer
func MarshalUShorts ¶
MarshalUShort marshals unsigned 16bit integer array format:
- TypeUShort
- 16bit count
- repeat: 16bit BE integer...
Types ¶
type Type ¶
type Type byte
const ( TypeNull Type = iota // C#:null TypeFalse // C#:bool (false) TypeTrue // C#:bool (true) TypeSByte // C#:sbyte TypeByte // C#:byte TypeChar // C#:char TypeShort // C#:short (16bit) TypeUShort // C#:ushort TypeInt // C#:int (32bit) TypeUInt // C#:uint TypeLong // C#:long (64bit) TypeULong // C#:ulong TypeFloat // C#:float TypeDouble // C#:double TypeDecimal // C#:decimal TypeStr8 // C#:string; lenght < 256 TypeStr16 // C#:string; lenght >= 256 TypeObj // C#:object TypeList // C#:List<object>; count < 256 TypeDict // C#:Dictionary<string, object>; count < 256; key length < 256 TypeBools // C#:bool[] TypeSBytes // C#:sbyte[] TypeBytes // C#:byte[] TypeChars // C#:char[] TypeShorts // C#:short[] TypeUShorts // C#:ushort[] TypeInts // C#:int[] TypeUInts // C#:uint[] TypeLongs // C#:long[] TypeULongs // C#:ulong[] TypeFloats // C#:float[] TypeDoubles // C#:double[] TypeDecimals // C#:decimal[] )