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

Method ReadBufferObject

go/fory/reader.go:669–699  ·  view source on GitHub ↗

ReadBufferObject reads a buffer object

()

Source from the content-addressed store, hash-verified

667
668// ReadBufferObject reads a buffer object
669func (c *ReadContext) ReadBufferObject() *ByteBuffer {
670 err := c.Err()
671 isInBand := c.buffer.ReadBool(err)
672 if isInBand {
673 size := c.ReadBinaryLength()
674 if c.HasError() {
675 return nil
676 }
677 if c.buffer.reader != nil {
678 bytes := c.buffer.ReadBytes(size, err)
679 if c.HasError() {
680 return nil
681 }
682 return NewByteBuffer(bytes)
683 }
684 if !c.buffer.CheckReadable(size, err) {
685 return nil
686 }
687 buf := c.buffer.Slice(c.buffer.readerIndex, size)
688 c.buffer.readerIndex += size
689 return buf
690 }
691 // Out-of-band: get the next buffer from the out-of-band buffers list
692 if c.outOfBandBuffers == nil || c.outOfBandIndex >= len(c.outOfBandBuffers) {
693 c.SetError(DeserializationErrorf("out-of-band buffer expected but not available at index %d", c.outOfBandIndex))
694 return nil
695 }
696 buf := c.outOfBandBuffers[c.outOfBandIndex]
697 c.outOfBandIndex++
698 return buf
699}
700
701// incDepth increments the nesting depth and checks for overflow
702func (c *ReadContext) incDepth() {

Calls 10

ErrMethod · 0.95
ReadBinaryLengthMethod · 0.95
HasErrorMethod · 0.95
SetErrorMethod · 0.95
NewByteBufferFunction · 0.85
DeserializationErrorfFunction · 0.85
CheckReadableMethod · 0.80
SliceMethod · 0.80
ReadBoolMethod · 0.45
ReadBytesMethod · 0.45