MCPcopy Create free account
hub / github.com/apache/fory / WriteStringSlice

Function WriteStringSlice

go/fory/slice_primitive.go:1406–1422  ·  view source on GitHub ↗

WriteStringSlice writes []string to buffer using LIST protocol. When hasGenerics is true (element type known from TypeDef/generics), uses IS_DECL_ELEMENT_TYPE and doesn't write element type ID. When false, writes element type ID.

(buf *ByteBuffer, value []string, hasGenerics bool)

Source from the content-addressed store, hash-verified

1404// When hasGenerics is true (element type known from TypeDef/generics), uses IS_DECL_ELEMENT_TYPE
1405// and doesn't write element type ID. When false, writes element type ID.
1406func WriteStringSlice(buf *ByteBuffer, value []string, hasGenerics bool) {
1407 length := len(value)
1408 buf.WriteVarUint32(uint32(length))
1409 if length > 0 {
1410 // Use CollectionDeclSameType when element type is known from TypeDef/generics
1411 // This matches Java's writeNullabilityHeader behavior for monomorphic types
1412 if hasGenerics {
1413 buf.WriteInt8(int8(CollectionDeclSameType))
1414 } else {
1415 buf.WriteInt8(int8(CollectionIsSameType))
1416 buf.WriteUint8(uint8(STRING))
1417 }
1418 for i := 0; i < length; i++ {
1419 writeString(buf, value[i])
1420 }
1421 }
1422}
1423
1424// ReadStringSlice reads []string from buffer using LIST protocol
1425func ReadStringSlice(buf *ByteBuffer, err *Error) []string {

Callers 1

WriteStringSliceMethod · 0.85

Calls 7

writeStringFunction · 0.85
WriteUint8Method · 0.80
uint32Function · 0.50
int8Function · 0.50
uint8Function · 0.50
WriteVarUint32Method · 0.45
WriteInt8Method · 0.45

Tested by

no test coverage detected