コード例 #1
0
ファイル: output_tag.go プロジェクト: henryanand/vitess
// MarshalBson bson-encodes MyType.
func (myType *MyType) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeInt(buf, "Local", myType.local)
	bson.EncodeInt(buf, "Local1", myType.Local2)

	lenWriter.Close()
}
コード例 #2
0
ファイル: charset_bson.go プロジェクト: henryanand/vitess
// MarshalBson bson-encodes Charset.
func (charset *Charset) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeInt(buf, "Client", charset.Client)
	bson.EncodeInt(buf, "Conn", charset.Conn)
	bson.EncodeInt(buf, "Server", charset.Server)

	lenWriter.Close()
}
コード例 #3
0
ファイル: output_int.go プロジェクト: henryanand/vitess
// MarshalBson bson-encodes MyType.
func (myType MyType) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	if key == "" {
		lenWriter := bson.NewLenWriter(buf)
		defer lenWriter.Close()
		key = bson.MAGICTAG
	}
	bson.EncodeInt(buf, key, int(myType))
}
コード例 #4
0
ファイル: zkstat_bson.go プロジェクト: henryanand/vitess
// 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()
}
コード例 #5
0
ファイル: statement_bson.go プロジェクト: henryanand/vitess
// MarshalBson bson-encodes Statement.
func (statement *Statement) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeInt(buf, "Category", statement.Category)
	// *mproto.Charset
	if statement.Charset == nil {
		bson.EncodePrefix(buf, bson.Null, "Charset")
	} else {
		(*statement.Charset).MarshalBson(buf, "Charset")
	}
	bson.EncodeBinary(buf, "Sql", statement.Sql)

	lenWriter.Close()
}
コード例 #6
0
ファイル: output_simple.go プロジェクト: henryanand/vitess
// 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()
}