ReadRefOrNull returns RefFlag if a ref to a previously read object was read. Returns NullFlag if the object is null. Returns RefValueFlag if the object is not null and ref tracking is not enabled or the object is first read.
(buffer *ByteBuffer, ctxErr *Error)
| 196 | // was read. Returns NullFlag if the object is null. Returns RefValueFlag if the object is not |
| 197 | // null and ref tracking is not enabled or the object is first read. |
| 198 | func (r *RefResolver) ReadRefOrNull(buffer *ByteBuffer, ctxErr *Error) int8 { |
| 199 | refTag := buffer.ReadInt8(ctxErr) |
| 200 | if !r.refTracking { |
| 201 | return refTag |
| 202 | } |
| 203 | if refTag == RefFlag { |
| 204 | // read ref id and get object from ref resolver |
| 205 | refId := buffer.ReadVarUint32(ctxErr) |
| 206 | r.readObject = r.GetReadObject(int32(refId)) |
| 207 | return RefFlag |
| 208 | } else { |
| 209 | r.readObject = reflect.Value{} |
| 210 | } |
| 211 | return refTag |
| 212 | } |
| 213 | |
| 214 | // PreserveRefId preserve a ref id, which is used by Reference / SetReadObject to |
| 215 | // set up reference for object that is first deserialized. |