package bin
import (
"encoding/binary"
"math"
)
func (b *Buffer ) PutID (id uint32 ) {
b .PutUint32 (id )
}
func (b *Buffer ) Put (raw []byte ) {
b .Buf = append (b .Buf , raw ...)
}
func (b *Buffer ) PutString (s string ) {
b .Buf = encodeString (b .Buf , s )
}
func (b *Buffer ) PutBytes (v []byte ) {
b .Buf = encodeBytes (b .Buf , v )
}
func (b *Buffer ) PutVectorHeader (length int ) {
b .PutID (TypeVector )
b .PutInt32 (int32 (length ))
}
func (b *Buffer ) PutInt (v int ) {
b .PutInt32 (int32 (v ))
}
func (b *Buffer ) PutBool (v bool ) {
switch v {
case true :
b .PutID (TypeTrue )
case false :
b .PutID (TypeFalse )
}
}
func (b *Buffer ) PutUint16 (v uint16 ) {
t := make ([]byte , 2 )
binary .LittleEndian .PutUint16 (t , v )
b .Buf = append (b .Buf , t ...)
}
func (b *Buffer ) PutInt32 (v int32 ) {
b .PutUint32 (uint32 (v ))
}
func (b *Buffer ) PutUint32 (v uint32 ) {
t := make ([]byte , Word )
binary .LittleEndian .PutUint32 (t , v )
b .Buf = append (b .Buf , t ...)
}
func (b *Buffer ) PutInt53 (v int64 ) {
b .PutLong (v )
}
func (b *Buffer ) PutLong (v int64 ) {
b .PutUint64 (uint64 (v ))
}
func (b *Buffer ) PutUint64 (v uint64 ) {
t := make ([]byte , Word *2 )
binary .LittleEndian .PutUint64 (t , v )
b .Buf = append (b .Buf , t ...)
}
func (b *Buffer ) PutDouble (v float64 ) {
b .PutUint64 (math .Float64bits (v ))
}
func (b *Buffer ) PutInt128 (v Int128 ) {
b .Buf = append (b .Buf , v [:]...)
}
func (b *Buffer ) PutInt256 (v Int256 ) {
b .Buf = append (b .Buf , v [:]...)
}
func (b *Buffer ) Reset () {
b .Buf = b .Buf [:0 ]
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .