func DecodeBool(buf *bytes.Buffer, kind byte) bool {
	switch kind {
	case Boolean:
		b, _ := buf.ReadByte()
		return (b != 0)
	case Int:
		return (Pack.Uint32(Next(buf, 4)) != 0)
	case Long, Ulong:
		return (Pack.Uint64(Next(buf, 8)) != 0)
	case Null:
		return false
	default:
		panic(NewBsonError("unexpected kind %v for bool", kind))
	}
}
DecodeBool decodes a bool from buf.
Allowed types: Boolean, Int, Long, Ulong, Null.
package bson
import (
	"bytes"
	"math"
	"time"
	"github.com/honeycombio/sqlparser/dependency/hack"
)
func VerifyObject(kind byte) {
	if kind != EOO && kind != Object {
		panic(NewBsonError("unexpected kind: %v", kind))
	}
}
func DecodeString(buf *bytes.Buffer, kind byte) string {
	switch kind {
	case String:
		l := int(Pack.Uint32(Next(buf, 4)))
		s := Next(buf, l-1)
		NextByte(buf)
		return string(s)
	case Binary:
		l := int(Pack.Uint32(Next(buf, 4)))
		NextByte(buf)
		return string(Next(buf, l))
	case Null:
		return ""
	}
	panic(NewBsonError("unexpected kind %v for string", kind))
}
func DecodeBinary(buf *bytes.Buffer, kind byte) []byte {
	switch kind {
	case String:
		l := int(Pack.Uint32(Next(buf, 4)))
		b := Next(buf, l-1)
		NextByte(buf)
		return b
	case Binary:
		l := int(Pack.Uint32(Next(buf, 4)))
		NextByte(buf)
		return Next(buf, l)
	case Null:
		return nil
	}
	panic(NewBsonError("unexpected kind %v for []byte", kind))
}
func DecodeInt64(buf *bytes.Buffer, kind byte) int64 {
	switch kind {
	case Int:
		return int64(int32(Pack.Uint32(Next(buf, 4))))
	case Long, Ulong:
		return int64(Pack.Uint64(Next(buf, 8)))
	case Null:
		return 0
	}
	panic(NewBsonError("unexpected kind %v for int64", kind))
}
func DecodeInt32(buf *bytes.Buffer, kind byte) int32 {
	switch kind {
	case Int:
		return int32(Pack.Uint32(Next(buf, 4)))
	case Null:
		return 0
	}
	panic(NewBsonError("unexpected kind %v for int32", kind))
}
func DecodeInt(buf *bytes.Buffer, kind byte) int {
	switch kind {
	case Int:
		return int(Pack.Uint32(Next(buf, 4)))
	case Long, Ulong:
		return int(Pack.Uint64(Next(buf, 8)))
	case Null:
		return 0
	}
	panic(NewBsonError("unexpected kind %v for int", kind))
}
func DecodeUint64(buf *bytes.Buffer, kind byte) uint64 {
	switch kind {
	case Int:
		return uint64(Pack.Uint32(Next(buf, 4)))
	case Long, Ulong:
		return Pack.Uint64(Next(buf, 8))
	case Null:
		return 0
	}
	panic(NewBsonError("unexpected kind %v for uint64", kind))
}
func DecodeUint32(buf *bytes.Buffer, kind byte) uint32 {
	switch kind {
	case Int:
		return Pack.Uint32(Next(buf, 4))
	case Ulong:
		return uint32(Pack.Uint64(Next(buf, 8)))
	case Null:
		return 0
	}
	panic(NewBsonError("unexpected kind %v for uint32", kind))
}
func DecodeUint(buf *bytes.Buffer, kind byte) uint {
	switch kind {
	case Int:
		return uint(Pack.Uint32(Next(buf, 4)))
	case Long, Ulong:
		return uint(Pack.Uint64(Next(buf, 8)))
	case Null:
		return 0
	}
	panic(NewBsonError("unexpected kind %v for uint", kind))
}
func DecodeFloat64(buf *bytes.Buffer, kind byte) float64 {
	switch kind {
	case Number:
		return float64(math.Float64frombits(Pack.Uint64(Next(buf, 8))))
	case Null:
		return 0
	}
	panic(NewBsonError("unexpected kind %v for float64", kind))
}