// UnmarshalBson bson-decodes into Statement. func (statement *Statement) UnmarshalBson(buf *bytes.Buffer, kind byte) { switch kind { case bson.EOO, bson.Object: // valid case bson.Null: return default: panic(bson.NewBsonError("unexpected kind %v for Statement", kind)) } bson.Next(buf, 4) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { switch bson.ReadCString(buf) { case "Category": statement.Category = bson.DecodeInt(buf, kind) case "Charset": // *mproto.Charset if kind != bson.Null { statement.Charset = new(mproto.Charset) (*statement.Charset).UnmarshalBson(buf, kind) } case "Sql": statement.Sql = bson.DecodeBinary(buf, kind) default: bson.Skip(buf, kind) } } }
func (v *Value) UnmarshalBson(buf *bytes.Buffer, kind byte) { if kind == bson.EOO { bson.Next(buf, 4) kind = bson.NextByte(buf) bson.ReadCString(buf) } if kind != bson.Null { *v = MakeString(bson.DecodeBinary(buf, kind)) } }
// UnmarshalBson bson-decodes into MyType. func (myType *MyType) UnmarshalBson(buf *bytes.Buffer, kind byte) { switch kind { case bson.EOO, bson.Object: // valid case bson.Null: return default: panic(bson.NewBsonError("unexpected kind %v for MyType", kind)) } bson.Next(buf, 4) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { switch bson.ReadCString(buf) { case "Float64": myType.Float64 = bson.DecodeFloat64(buf, kind) case "String": myType.String = bson.DecodeString(buf, kind) case "Bool": myType.Bool = bson.DecodeBool(buf, kind) case "Int64": myType.Int64 = bson.DecodeInt64(buf, kind) case "Int32": myType.Int32 = bson.DecodeInt32(buf, kind) case "Int": myType.Int = bson.DecodeInt(buf, kind) case "Uint64": myType.Uint64 = bson.DecodeUint64(buf, kind) case "Uint32": myType.Uint32 = bson.DecodeUint32(buf, kind) case "Uint": myType.Uint = bson.DecodeUint(buf, kind) case "Bytes": myType.Bytes = bson.DecodeBinary(buf, kind) case "Time": myType.Time = bson.DecodeTime(buf, kind) case "Interface": myType.Interface = bson.DecodeInterface(buf, kind) default: bson.Skip(buf, kind) } } }
// UnmarshalBson bson-decodes into MyType. func (myType *MyType) UnmarshalBson(buf *bytes.Buffer, kind byte) { switch kind { case bson.EOO, bson.Object: // valid case bson.Null: return default: panic(bson.NewBsonError("unexpected kind %v for MyType", kind)) } bson.Next(buf, 4) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { switch bson.ReadCString(buf) { case "Ptr": // *int64 if kind != bson.Null { myType.Ptr = new(int64) (*myType.Ptr) = bson.DecodeInt64(buf, kind) } case "PtrPtr": // **int64 if kind != bson.Null { myType.PtrPtr = new(*int64) // *int64 if kind != bson.Null { (*myType.PtrPtr) = new(int64) (*(*myType.PtrPtr)) = bson.DecodeInt64(buf, kind) } } case "PtrBytes": // *[]byte if kind != bson.Null { myType.PtrBytes = new([]byte) (*myType.PtrBytes) = bson.DecodeBinary(buf, kind) } case "PtrSlice": // *[]int64 if kind != bson.Null { myType.PtrSlice = new([]int64) // []int64 if kind != bson.Null { if kind != bson.Array { panic(bson.NewBsonError("unexpected kind %v for (*myType.PtrSlice)", kind)) } bson.Next(buf, 4) (*myType.PtrSlice) = make([]int64, 0, 8) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { bson.SkipIndex(buf) var _v1 int64 _v1 = bson.DecodeInt64(buf, kind) (*myType.PtrSlice) = append((*myType.PtrSlice), _v1) } } } case "PtrMap": // *map[string]int64 if kind != bson.Null { myType.PtrMap = new(map[string]int64) // map[string]int64 if kind != bson.Null { if kind != bson.Object { panic(bson.NewBsonError("unexpected kind %v for (*myType.PtrMap)", kind)) } bson.Next(buf, 4) (*myType.PtrMap) = make(map[string]int64) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { _k := bson.ReadCString(buf) var _v2 int64 _v2 = bson.DecodeInt64(buf, kind) (*myType.PtrMap)[_k] = _v2 } } } case "PtrCustom": // *Custom if kind != bson.Null { myType.PtrCustom = new(Custom) (*myType.PtrCustom).UnmarshalBson(buf, kind) } default: bson.Skip(buf, kind) } } }
// UnmarshalBson bson-decodes into MyType. func (myType *MyType) UnmarshalBson(buf *bytes.Buffer, kind byte) { switch kind { case bson.EOO, bson.Object: // valid case bson.Null: return default: panic(bson.NewBsonError("unexpected kind %v for MyType", kind)) } bson.Next(buf, 4) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { switch bson.ReadCString(buf) { case "Map": // map[string]string if kind != bson.Null { if kind != bson.Object { panic(bson.NewBsonError("unexpected kind %v for myType.Map", kind)) } bson.Next(buf, 4) myType.Map = make(map[string]string) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { _k := bson.ReadCString(buf) var _v1 string _v1 = bson.DecodeString(buf, kind) myType.Map[_k] = _v1 } } case "MapBytes": // map[string][]byte if kind != bson.Null { if kind != bson.Object { panic(bson.NewBsonError("unexpected kind %v for myType.MapBytes", kind)) } bson.Next(buf, 4) myType.MapBytes = make(map[string][]byte) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { _k := bson.ReadCString(buf) var _v2 []byte _v2 = bson.DecodeBinary(buf, kind) myType.MapBytes[_k] = _v2 } } case "MapPtr": // map[string]*string if kind != bson.Null { if kind != bson.Object { panic(bson.NewBsonError("unexpected kind %v for myType.MapPtr", kind)) } bson.Next(buf, 4) myType.MapPtr = make(map[string]*string) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { _k := bson.ReadCString(buf) var _v3 *string // *string if kind != bson.Null { _v3 = new(string) (*_v3) = bson.DecodeString(buf, kind) } myType.MapPtr[_k] = _v3 } } case "MapSlice": // map[string][]string if kind != bson.Null { if kind != bson.Object { panic(bson.NewBsonError("unexpected kind %v for myType.MapSlice", kind)) } bson.Next(buf, 4) myType.MapSlice = make(map[string][]string) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { _k := bson.ReadCString(buf) var _v4 []string // []string if kind != bson.Null { if kind != bson.Array { panic(bson.NewBsonError("unexpected kind %v for _v4", kind)) } bson.Next(buf, 4) _v4 = make([]string, 0, 8) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { bson.SkipIndex(buf) var _v5 string _v5 = bson.DecodeString(buf, kind) _v4 = append(_v4, _v5) } } myType.MapSlice[_k] = _v4 } } case "MapMap": // map[string]map[string]int64 if kind != bson.Null { if kind != bson.Object { panic(bson.NewBsonError("unexpected kind %v for myType.MapMap", kind)) } bson.Next(buf, 4) myType.MapMap = make(map[string]map[string]int64) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { _k := bson.ReadCString(buf) var _v6 map[string]int64 // map[string]int64 if kind != bson.Null { if kind != bson.Object { panic(bson.NewBsonError("unexpected kind %v for _v6", kind)) } bson.Next(buf, 4) _v6 = make(map[string]int64) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { _k := bson.ReadCString(buf) var _v7 int64 _v7 = bson.DecodeInt64(buf, kind) _v6[_k] = _v7 } } myType.MapMap[_k] = _v6 } } case "MapCustom": // map[string]Custom if kind != bson.Null { if kind != bson.Object { panic(bson.NewBsonError("unexpected kind %v for myType.MapCustom", kind)) } bson.Next(buf, 4) myType.MapCustom = make(map[string]Custom) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { _k := bson.ReadCString(buf) var _v8 Custom _v8.UnmarshalBson(buf, kind) myType.MapCustom[_k] = _v8 } } case "MapCustomPtr": // map[string]*Custom if kind != bson.Null { if kind != bson.Object { panic(bson.NewBsonError("unexpected kind %v for myType.MapCustomPtr", kind)) } bson.Next(buf, 4) myType.MapCustomPtr = make(map[string]*Custom) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { _k := bson.ReadCString(buf) var _v9 *Custom // *Custom if kind != bson.Null { _v9 = new(Custom) (*_v9).UnmarshalBson(buf, kind) } myType.MapCustomPtr[_k] = _v9 } } case "CustomMap": // map[Custom]string if kind != bson.Null { if kind != bson.Object { panic(bson.NewBsonError("unexpected kind %v for myType.CustomMap", kind)) } bson.Next(buf, 4) myType.CustomMap = make(map[Custom]string) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { _k := Custom(bson.ReadCString(buf)) var _v10 string _v10 = bson.DecodeString(buf, kind) myType.CustomMap[_k] = _v10 } } case "MapExternal": // map[pkg.Custom]string if kind != bson.Null { if kind != bson.Object { panic(bson.NewBsonError("unexpected kind %v for myType.MapExternal", kind)) } bson.Next(buf, 4) myType.MapExternal = make(map[pkg.Custom]string) for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) { _k := pkg.Custom(bson.ReadCString(buf)) var _v11 string _v11 = bson.DecodeString(buf, kind) myType.MapExternal[_k] = _v11 } } default: bson.Skip(buf, kind) } } }