(ctx *ReadContext, value reflect.Value)
| 645 | } |
| 646 | |
| 647 | func (s stringSliceSerializer) ReadData(ctx *ReadContext, value reflect.Value) { |
| 648 | buf := ctx.Buffer() |
| 649 | ctxErr := ctx.Err() |
| 650 | length := ctx.ReadCollectionLength() |
| 651 | if ctx.HasError() { |
| 652 | return |
| 653 | } |
| 654 | ptr := (*[]string)(value.Addr().UnsafePointer()) |
| 655 | if length == 0 { |
| 656 | *ptr = make([]string, 0) |
| 657 | return |
| 658 | } |
| 659 | |
| 660 | // Read collection flags |
| 661 | collectFlag := buf.ReadInt8(ctxErr) |
| 662 | if ctx.HasError() { |
| 663 | return |
| 664 | } |
| 665 | |
| 666 | // Read element type info if present (when CollectionIsSameType but not CollectionIsDeclElementType) |
| 667 | if (collectFlag&CollectionIsSameType) != 0 && (collectFlag&CollectionIsDeclElementType) == 0 { |
| 668 | _ = buf.ReadUint8(ctxErr) // Read and discard type ID (we know it's STRING) |
| 669 | } |
| 670 | if ctx.HasError() { |
| 671 | return |
| 672 | } |
| 673 | if !buf.CheckReadable(length, ctxErr) { |
| 674 | return |
| 675 | } |
| 676 | |
| 677 | result := make([]string, length) |
| 678 | |
| 679 | // Check if remote sent with ref tracking (handle both cases for compatibility) |
| 680 | trackRefs := (collectFlag & CollectionTrackingRef) != 0 |
| 681 | |
| 682 | // Read elements |
| 683 | for i := 0; i < length; i++ { |
| 684 | if trackRefs { |
| 685 | refFlag := buf.ReadInt8(ctxErr) |
| 686 | if refFlag == NullFlag { |
| 687 | continue // null string, leave as zero value |
| 688 | } |
| 689 | } |
| 690 | result[i] = readString(buf, ctxErr) |
| 691 | } |
| 692 | *ptr = result |
| 693 | } |
| 694 | |
| 695 | func stringSliceValue(value reflect.Value) []string { |
| 696 | if value.CanAddr() { |
no test coverage detected