Beispiel #1
0
// MarshalBson bson-encodes ZkStat.
func (zkStat *ZkStat) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeInt64(buf, "Czxid", zkStat.czxid)
	bson.EncodeInt64(buf, "Mzxid", zkStat.mzxid)
	bson.EncodeTime(buf, "CTime", zkStat.cTime)
	bson.EncodeTime(buf, "MTime", zkStat.mTime)
	bson.EncodeInt(buf, "Version", zkStat.version)
	bson.EncodeInt(buf, "CVersion", zkStat.cVersion)
	bson.EncodeInt(buf, "AVersion", zkStat.aVersion)
	bson.EncodeInt64(buf, "EphemeralOwner", zkStat.ephemeralOwner)
	bson.EncodeInt(buf, "DataLength", zkStat.dataLength)
	bson.EncodeInt(buf, "NumChildren", zkStat.numChildren)
	bson.EncodeInt64(buf, "Pzxid", zkStat.pzxid)

	lenWriter.Close()
}
Beispiel #2
0
func (zkStat *ZkStat) MarshalBson(buf *bytes2.ChunkedWriter) {
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeInt64(buf, "Czxid", zkStat.czxid)
	bson.EncodeInt64(buf, "Mzxid", zkStat.mzxid)
	bson.EncodeTime(buf, "CTime", zkStat.cTime)
	bson.EncodeTime(buf, "MTime", zkStat.mTime)
	bson.EncodeInt32(buf, "Version", int32(zkStat.version))
	bson.EncodeInt32(buf, "CVersion", int32(zkStat.cVersion))
	bson.EncodeInt32(buf, "AVersion", int32(zkStat.aVersion))
	bson.EncodeInt64(buf, "EphemeralOwner", zkStat.ephemeralOwner)
	bson.EncodeInt32(buf, "DataLength", int32(zkStat.dataLength))
	bson.EncodeInt32(buf, "NumChildren", int32(zkStat.numChildren))
	bson.EncodeInt64(buf, "Pzxid", zkStat.pzxid)

	buf.WriteByte(0)
	lenWriter.RecordLen()
}
// MarshalBson bson-encodes A.
func (a *A) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeString(buf, "Name", a.Name)
	bson.EncodeTime(buf, "BirthDay", a.BirthDay)
	bson.EncodeString(buf, "Phone", a.Phone)
	bson.EncodeInt(buf, "Siblings", a.Siblings)
	bson.EncodeBool(buf, "Spouse", a.Spouse)
	bson.EncodeFloat64(buf, "Money", a.Money)

	lenWriter.Close()
}
Beispiel #4
0
// MarshalBson bson-encodes MyType.
func (myType *MyType) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeFloat64(buf, "Float64", myType.Float64)
	bson.EncodeString(buf, "String", myType.String)
	bson.EncodeBool(buf, "Bool", myType.Bool)
	bson.EncodeInt64(buf, "Int64", myType.Int64)
	bson.EncodeInt32(buf, "Int32", myType.Int32)
	bson.EncodeInt(buf, "Int", myType.Int)
	bson.EncodeUint64(buf, "Uint64", myType.Uint64)
	bson.EncodeUint32(buf, "Uint32", myType.Uint32)
	bson.EncodeUint(buf, "Uint", myType.Uint)
	bson.EncodeBinary(buf, "Bytes", myType.Bytes)
	bson.EncodeTime(buf, "Time", myType.Time)
	bson.EncodeInterface(buf, "Interface", myType.Interface)

	lenWriter.Close()
}