本文整理匯總了Golang中github.com/h00gs/gubed.Logger.DecodeError方法的典型用法代碼示例。如果您正苦於以下問題:Golang Logger.DecodeError方法的具體用法?Golang Logger.DecodeError怎麽用?Golang Logger.DecodeError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/h00gs/gubed.Logger
的用法示例。
在下文中一共展示了Logger.DecodeError方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetType
// Read the first bytes of the given byte slice to return the LBTYPE.
func GetType(x []byte, debug *gubed.Logger) (typ LBTYPE) {
if len(x) < LBTYPE_SIZE {
debug.Error(FmtErrSliceTooSmall(x, LBTYPE_SIZE))
}
bfr := bufio.NewReader(bytes.NewBuffer(x[:LBTYPE_SIZE]))
debug.DecodeError(binary.Read(bfr, BIGEND, &typ))
return
}
示例2: ToIndexRecord
// Map GenericRecord to a new IndexRecord.
func (rec *GenericRecord) ToIndexRecord(debug *gubed.Logger) *IndexRecord {
irec := NewIndexRecord()
irec.ksz = rec.ksz
irec.kbyts = rec.kbyts
irec.ktype = rec.ktype
// Unpack
bfr := bufio.NewReader(bytes.NewBuffer(rec.vbyts))
debug.DecodeError(binary.Read(bfr, BIGEND, &irec.vsz))
debug.DecodeError(binary.Read(bfr, BIGEND, &irec.vpos))
return irec
}
示例3: FromBytes
func (fmap *FieldMap) FromBytes(bfr *bytes.Buffer, debug *gubed.Logger) (err error) {
var size LBUINT
var label string
var vtype LBTYPE
var bits []byte
for bfr.Len() > 0 {
err = debug.DecodeError(binary.Read(bfr, BIGEND, &size)) // label size
if err == io.EOF {
break
} else {
if err != nil {
return
}
}
bits = make([]byte, int(size))
err = debug.DecodeError(binary.Read(bfr, BIGEND, &bits))
if err == io.EOF {
break
} else {
if err != nil {
return
}
}
label = string(bits) // label
err = debug.DecodeError(binary.Read(bfr, BIGEND, &size)) // value size
if err == io.EOF {
break
} else {
if err != nil {
return
}
}
bits = make([]byte, int(size)-LBTYPE_SIZE)
err = debug.DecodeError(binary.Read(bfr, BIGEND, &vtype)) // LBTYPE
if err == io.EOF {
break
} else {
if err != nil {
return
}
}
err = debug.DecodeError(binary.Read(bfr, BIGEND, &bits))
fmap.fields[label] = MakeField(bits, vtype)
if err == io.EOF {
break
} else {
if err != nil {
return
}
}
}
return
}
示例4: ToLogRecord
// Map GenericRecord to a new LogRecord.
func (rec *GenericRecord) ToLogRecord(debug *gubed.Logger) *LogRecord {
lrec := NewLogRecord()
lrec.ksz = rec.ksz
lrec.vsz = rec.vsz - CRC_SIZE
lrec.kbyts = rec.kbyts
lrec.ktype = rec.ktype
lrec.vtype = rec.vtype
// Unpack
bfr := bufio.NewReader(bytes.NewBuffer(rec.vbyts))
// Note that the generic vsz includes the LBTYPE prefix
lrec.vbyts = make([]byte, int(lrec.vsz)-LBTYPE_SIZE) // must have fixed size
debug.DecodeError(binary.Read(bfr, BIGEND, &lrec.vbyts))
debug.DecodeError(binary.Read(bfr, BIGEND, &lrec.crc))
return lrec
}
示例5: ToValueLocation
// Map GenericRecord to a new MasterLogRecord.
func (rec *GenericRecord) ToValueLocation(debug *gubed.Logger) (interface{}, *ValueLocation) {
key, err := MakeKey(rec.kbyts, rec.ktype, debug)
debug.Error(err)
vbyts, _ := rec.GetValueAndType(MASTER_RECORD, debug)
vloc := NewValueLocation()
// Unpack
bfr := bufio.NewReader(bytes.NewBuffer(vbyts))
debug.DecodeError(binary.Read(bfr, BIGEND, &vloc.fnum))
debug.DecodeError(binary.Read(bfr, BIGEND, &vloc.vsz))
debug.DecodeError(binary.Read(bfr, BIGEND, &vloc.vpos))
return key, vloc
}
示例6: ToZapRecordList
// Map GenericRecord to a new ZapRecord list.
func (rec *GenericRecord) ToZapRecordList(debug *gubed.Logger) (interface{}, []*ZapRecord) {
key, err := MakeKey(rec.kbyts, rec.ktype, debug)
debug.Error(err)
n := rec.LocationListLength()
bfr := bufio.NewReader(bytes.NewBuffer(rec.vbyts))
var zrecs = make([]*ZapRecord, n)
for i := 0; i < n; i++ {
zrecs[i] = NewZapRecord()
debug.DecodeError(binary.Read(bfr, BIGEND, &zrecs[i].fnum))
debug.DecodeError(binary.Read(bfr, BIGEND, &zrecs[i].rsz))
debug.DecodeError(binary.Read(bfr, BIGEND, &zrecs[i].rpos))
}
return key, zrecs
}
示例7: BytesToCatalogId
// Read an CATID from a byte slice.
func BytesToCatalogId(byts []byte, debug *gubed.Logger) (interface{}, error) {
bfr := bytes.NewBuffer(byts)
var cid CATID_TYPE
err := debug.DecodeError(binary.Read(bfr, BIGEND, &cid))
return cid, err
}
示例8: SnipKeyType
func SnipKeyType(key []byte, debug *gubed.Logger) (newkey []byte, ktype LBTYPE) {
bfr := bufio.NewReader(bytes.NewBuffer(key[:LBTYPE_SIZE]))
debug.DecodeError(binary.Read(bfr, BIGEND, &ktype))
newkey = key[LBTYPE_SIZE:]
return
}