func oneFieldTuple(r *marshal.Reader, sz int) bool { var l, s int if l = r.IntUint32(); l >= 1 { if s = r.Intvar(); s == sz { return true } else { r.Err = fmt.Errorf("Wrong field size: expect 1, got %d", l) } } else { r.Err = fmt.Errorf("Wrong field count: expect 1, got %d", l) } return false }
func ReadSizedTuple(r *marshal.Reader, i interface{}) error { sz := r.IntUint32() if r.Err == nil { rd := marshal.Reader{Body: r.Slice(sz + 4)} r.Err = ReadRawTuple(&rd, i) } return r.Err }
func (t *TReader) string(r *marshal.Reader, v reflect.Value) { if l := r.Uint32(); l >= 1 { sz := r.Intvar() v.SetString(r.String(sz)) } else { r.Err = fmt.Errorf("Wrong field count: expect 1, got %d", l) } }
func (t *TReader) sliceFixed(r *marshal.Reader, v reflect.Value) { if l := r.IntUint32(); l >= v.Len() { for i := 0; i < l; i++ { t.Reader.Elem.WithSize(r, v.Index(i), (*marshal.Reader).Intvar) } } else { r.Err = fmt.Errorf("Wrong field count: expect %d, got %d", v.Len(), l) } }
func (t *TReader) bytesAuto(r *marshal.Reader, v reflect.Value) { if !v.CanSet() { t.bytesFixed(r, v) return } if l := r.IntUint32(); l >= 1 { t.Reader.WithSize(r, v, (*marshal.Reader).Intvar) } else { r.Err = fmt.Errorf("Wrong field count: expect 1, got %d", l) } }
func (t *TReader) sliceAuto(r *marshal.Reader, v reflect.Value) { l := r.IntUint32() if v.CanSet() { v.Set(reflect.MakeSlice(v.Type(), l, l)) } else if l < v.Len() { r.Err = fmt.Errorf("Wrong field count: expect %d, got %d", v.Len(), l) return } for i := 0; i < l; i++ { t.Reader.Elem.WithSize(r, v.Index(i), (*marshal.Reader).Intvar) } }