当前位置: 首页>>代码示例>>Golang>>正文


Golang Reader.ReadNil方法代码示例

本文整理汇总了Golang中github.com/tinylib/msgp/msgp.Reader.ReadNil方法的典型用法代码示例。如果您正苦于以下问题:Golang Reader.ReadNil方法的具体用法?Golang Reader.ReadNil怎么用?Golang Reader.ReadNil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/tinylib/msgp/msgp.Reader的用法示例。


在下文中一共展示了Reader.ReadNil方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: DecodeMsg

// DecodeMsg implements msgp.Decodable
func (z *MetricDataArray) DecodeMsg(dc *msgp.Reader) (err error) {
	var xsz uint32
	xsz, err = dc.ReadArrayHeader()
	if err != nil {
		return
	}
	if cap((*z)) >= int(xsz) {
		(*z) = (*z)[:xsz]
	} else {
		(*z) = make(MetricDataArray, xsz)
	}
	for bai := range *z {
		if dc.IsNil() {
			err = dc.ReadNil()
			if err != nil {
				return
			}
			(*z)[bai] = nil
		} else {
			if (*z)[bai] == nil {
				(*z)[bai] = new(MetricData)
			}
			err = (*z)[bai].DecodeMsg(dc)
			if err != nil {
				return
			}
		}
	}
	return
}
开发者ID:aglagla,项目名称:raintank-metric,代码行数:31,代码来源:metric_gen.go

示例2: DecodeMsg

// DecodeMsg implements msgp.Decodable
func (z *runIterator32) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var zqke uint32
	zqke, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for zqke > 0 {
		zqke--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "rc":
			if dc.IsNil() {
				err = dc.ReadNil()
				if err != nil {
					return
				}
				z.rc = nil
			} else {
				if z.rc == nil {
					z.rc = new(runContainer32)
				}
				err = z.rc.DecodeMsg(dc)
				if err != nil {
					return
				}
			}
		case "curIndex":
			z.curIndex, err = dc.ReadInt64()
			if err != nil {
				return
			}
		case "curPosInIndex":
			z.curPosInIndex, err = dc.ReadUint32()
			if err != nil {
				return
			}
		case "curSeq":
			z.curSeq, err = dc.ReadInt64()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
开发者ID:RoaringBitmap,项目名称:roaring,代码行数:56,代码来源:rle_gen.go

示例3: DecodeMsg

// DecodeMsg implements msgp.Decodable
func (z *Message) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "id":
			z.ID, err = dc.ReadUint64()
			if err != nil {
				return
			}
		case "fn":
			z.Func, err = dc.ReadString()
			if err != nil {
				return
			}
		case "args":
			err = z.Args.DecodeMsg(dc)
			if err != nil {
				return
			}
		case "result":
			err = z.Result.DecodeMsg(dc)
			if err != nil {
				return
			}
		case "error":
			if dc.IsNil() {
				err = dc.ReadNil()
				if err != nil {
					return
				}
				z.Error = nil
			} else {
				if z.Error == nil {
					z.Error = new(Error)
				}
				var isz uint32
				isz, err = dc.ReadMapHeader()
				if err != nil {
					return
				}
				for isz > 0 {
					isz--
					field, err = dc.ReadMapKeyPtr()
					if err != nil {
						return
					}
					switch msgp.UnsafeString(field) {
					case "msg":
						z.Error.Msg, err = dc.ReadString()
						if err != nil {
							return
						}
					default:
						err = dc.Skip()
						if err != nil {
							return
						}
					}
				}
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
开发者ID:sztanpet,项目名称:bimpc,代码行数:81,代码来源:mpc_gen.go

示例4: DecodeMsg

// DecodeMsg implements msgp.Decodable
func (z *bitmapContainerShortIterator) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var zhct uint32
	zhct, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for zhct > 0 {
		zhct--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "ptr":
			if dc.IsNil() {
				err = dc.ReadNil()
				if err != nil {
					return
				}
				z.ptr = nil
			} else {
				if z.ptr == nil {
					z.ptr = new(bitmapContainer)
				}
				var zcua uint32
				zcua, err = dc.ReadMapHeader()
				if err != nil {
					return
				}
				for zcua > 0 {
					zcua--
					field, err = dc.ReadMapKeyPtr()
					if err != nil {
						return
					}
					switch msgp.UnsafeString(field) {
					case "cardinality":
						z.ptr.cardinality, err = dc.ReadInt()
						if err != nil {
							return
						}
					case "bitmap":
						var zxhx uint32
						zxhx, err = dc.ReadArrayHeader()
						if err != nil {
							return
						}
						if cap(z.ptr.bitmap) >= int(zxhx) {
							z.ptr.bitmap = (z.ptr.bitmap)[:zxhx]
						} else {
							z.ptr.bitmap = make([]uint64, zxhx)
						}
						for zwht := range z.ptr.bitmap {
							z.ptr.bitmap[zwht], err = dc.ReadUint64()
							if err != nil {
								return
							}
						}
					default:
						err = dc.Skip()
						if err != nil {
							return
						}
					}
				}
			}
		case "i":
			z.i, err = dc.ReadInt()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
开发者ID:RoaringBitmap,项目名称:roaring,代码行数:83,代码来源:bitmapcontainer_gen.go

示例5: DecodeMsg

// DecodeMsg implements msgp.Decodable
func (z *ServerResponse) DecodeMsg(dc *msgp.Reader) (err error) {
	{
		var ssz uint32
		ssz, err = dc.ReadArrayHeader()
		if err != nil {
			return
		}
		if ssz != 3 {
			err = msgp.ArrayError{Wanted: 3, Got: ssz}
			return
		}
	}
	if dc.IsNil() {
		err = dc.ReadNil()
		if err != nil {
			return
		}
		z.Header = nil
	} else {
		if z.Header == nil {
			z.Header = new(EventHeader)
		}
		var field []byte
		_ = field
		var isz uint32
		isz, err = dc.ReadMapHeader()
		if err != nil {
			return
		}
		for isz > 0 {
			isz--
			field, err = dc.ReadMapKeyPtr()
			if err != nil {
				return
			}
			switch msgp.UnsafeString(field) {
			case "message_id":
				z.Header.Id, err = dc.ReadString()
				if err != nil {
					return
				}
			case "v":
				z.Header.Version, err = dc.ReadInt()
				if err != nil {
					return
				}
			case "response_to":
				z.Header.ResponseTo, err = dc.ReadString()
				if err != nil {
					return
				}
			default:
				err = dc.Skip()
				if err != nil {
					return
				}
			}
		}
	}
	z.Name, err = dc.ReadString()
	if err != nil {
		return
	}
	var xsz uint32
	xsz, err = dc.ReadArrayHeader()
	if err != nil {
		return
	}
	if cap(z.Params) >= int(xsz) {
		z.Params = z.Params[:xsz]
	} else {
		z.Params = make([]interface{}, xsz)
	}
	for bzg := range z.Params {
		z.Params[bzg], err = dc.ReadIntf()
		if err != nil {
			return
		}
	}
	return
}
开发者ID:mengzhuo,项目名称:zerorpc-golang,代码行数:82,代码来源:protocal_gen.go

示例6: DecodeMsg

func (r *Response) DecodeMsg(mr *msgp.Reader) error {
	var bm msgp.Decodable

	if r.Body != nil {
		var ok bool
		bm, ok = r.Body.(msgp.Decodable)
		if !ok {
			return ErrNotDecodable
		}
	}

	if size, err := mr.ReadArrayHeader(); err != nil {
		return err
	} else if size != ResponsePackSize {
		return ErrBadPackSize
	}

	if typ, err := mr.ReadInt(); err != nil {
		return err
	} else if typ != ResponseType {
		return ErrBadMessageType
	}

	id, err := mr.ReadUint32()
	if err != nil {
		return err
	}

	r.ID = id

	// Error can be nil or a string.
	typ, err := mr.NextType()
	if err != nil {
		return err
	}

	switch typ {
	case msgp.StrType:
		s, err := mr.ReadString()
		if err != nil {
			return err
		}
		r.Error = s

	case msgp.NilType:
		if err := mr.ReadNil(); err != nil {
			return err
		}
		r.Error = ""

	default:
		return ErrBadErrorType
	}

	// Body can be nil.
	typ, err = mr.NextType()
	if err != nil {
		return err
	}

	if typ == msgp.NilType {
		r.hasBody = false
		return mr.ReadNil()
	}

	r.hasBody = true

	// Skip decoding the body if no value is present to decode into.
	// The caller is expected to read the body or skip it.
	if bm != nil {
		return decodeBody(mr, bm)
	}

	return nil

}
开发者ID:micro,项目名称:go-plugins,代码行数:76,代码来源:rpc.go


注:本文中的github.com/tinylib/msgp/msgp.Reader.ReadNil方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。