本文整理汇总了Golang中github.com/corestoreio/csfw/util/sqlparser/dependency/bytes2.ChunkedWriter类的典型用法代码示例。如果您正苦于以下问题:Golang ChunkedWriter类的具体用法?Golang ChunkedWriter怎么用?Golang ChunkedWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ChunkedWriter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: EncodeString
// EncodeString encodes a string.
func EncodeString(buf *bytes2.ChunkedWriter, key string, val string) {
// Encode strings as binary; go strings are not necessarily unicode
EncodePrefix(buf, Binary, key)
putUint32(buf, uint32(len(val)))
buf.WriteByte(0)
buf.WriteString(val)
}
示例2: EncodeBool
// EncodeBool encodes a bool.
func EncodeBool(buf *bytes2.ChunkedWriter, key string, val bool) {
EncodePrefix(buf, Boolean, key)
if val {
buf.WriteByte(1)
} else {
buf.WriteByte(0)
}
}
示例3: putUint64
func putUint64(buf *bytes2.ChunkedWriter, val uint64) {
Pack.PutUint64(buf.Reserve(WORD64), val)
}
示例4: putUint32
func putUint32(buf *bytes2.ChunkedWriter, val uint32) {
Pack.PutUint32(buf.Reserve(WORD32), val)
}
示例5: NewLenWriter
// NewLenWriter returns a LenWriter that reserves the
// bytes buf so they can store the length later.
func NewLenWriter(buf *bytes2.ChunkedWriter) LenWriter {
off := buf.Len()
b := buf.Reserve(WORD32)
return LenWriter{buf, off, b}
}
示例6: EncodeBinary
// EncodeBinary encodes a []byte as binary.
func EncodeBinary(buf *bytes2.ChunkedWriter, key string, val []byte) {
EncodePrefix(buf, Binary, key)
putUint32(buf, uint32(len(val)))
buf.WriteByte(0)
buf.Write(val)
}
示例7: EncodePrefix
// EncodePrefix encodes key as prefix for the next object or value.
func EncodePrefix(buf *bytes2.ChunkedWriter, etype byte, key string) {
b := buf.Reserve(len(key) + 2)
b[0] = etype
copy(b[1:], key)
b[len(b)-1] = 0
}