package msgpack
import (
)
func ( *Decoder) ( byte) (int, error) {
if == msgpcode.Nil {
return -1, nil
}
if msgpcode.IsFixedString() {
return int( & msgpcode.FixedStrMask), nil
}
switch {
case msgpcode.Str8, msgpcode.Bin8:
, := .uint8()
return int(),
case msgpcode.Str16, msgpcode.Bin16:
, := .uint16()
return int(),
case msgpcode.Str32, msgpcode.Bin32:
, := .uint32()
return int(),
}
return 0, fmt.Errorf("msgpack: invalid code=%x decoding string/bytes length", )
}
func ( *Decoder) () (string, error) {
if := .flags&useInternedStringsFlag != 0; || len(.dict) > 0 {
return .decodeInternedString()
}
, := .readCode()
if != nil {
return "",
}
return .string()
}
func ( *Decoder) ( byte) (string, error) {
, := .bytesLen()
if != nil {
return "",
}
return .stringWithLen()
}
func ( *Decoder) ( int) (string, error) {
if <= 0 {
return "", nil
}
, := .readN()
return string(),
}
func ( *Decoder, reflect.Value) error {
, := .DecodeString()
if != nil {
return
}
.SetString()
return nil
}
func ( *Decoder) () (int, error) {
, := .readCode()
if != nil {
return 0,
}
return .bytesLen()
}
func ( *Decoder) () ([]byte, error) {
, := .readCode()
if != nil {
return nil,
}
return .bytes(, nil)
}
func ( *Decoder) ( byte, []byte) ([]byte, error) {
, := .bytesLen()
if != nil {
return nil,
}
if == -1 {
return nil, nil
}
return readN(.r, , )
}
func ( *Decoder) () (string, error) {
if := .flags&useInternedStringsFlag != 0; || len(.dict) > 0 {
return .decodeInternedString()
}
, := .readCode()
if != nil {
return "",
}
, := .bytesLen()
if != nil {
return "",
}
if == -1 {
return "", nil
}
, := .readN()
if != nil {
return "",
}
return bytesToString(), nil
}
func ( *Decoder) ( *[]byte) error {
, := .readCode()
if != nil {
return
}
return .bytesPtr(, )
}
func ( *Decoder) ( byte, *[]byte) error {
, := .bytesLen()
if != nil {
return
}
if == -1 {
* = nil
return nil
}
*, = readN(.r, *, )
return
}
func ( *Decoder) ( byte) error {
, := .bytesLen()
if != nil {
return
}
if <= 0 {
return nil
}
return .skipN()
}
func ( *Decoder, reflect.Value) error {
, := .readCode()
if != nil {
return
}
, := .bytes(, .Bytes())
if != nil {
return
}
.SetBytes()
return nil
}
func ( *Decoder, reflect.Value) error {
, := .readCode()
if != nil {
return
}
, := .bytesLen()
if != nil {
return
}
if == -1 {
return nil
}
if > .Len() {
return fmt.Errorf("%s len is %d, but msgpack has %d elements", .Type(), .Len(), )
}
:= .Slice(0, ).Bytes()
return .readFull()
}