Next returns the body of the next value along with a boolean that is true if the value is a container. It returns an empty slice for an empty or zero-length value and nil for a super null value. The container boolean is not meaningful if the returned Bytes slice is nil. Next panics if the next va
()
| 19 | // meaningful if the returned Bytes slice is nil. Next panics if the next value |
| 20 | // is malformed. |
| 21 | func (i *Iter) Next() Bytes { |
| 22 | // The tag is zero for a null value; otherwise, it is the value's |
| 23 | // length plus one. |
| 24 | u64, n := binary.Uvarint(*i) |
| 25 | if n <= 0 { |
| 26 | panic(fmt.Sprintf("bad uvarint: %d", n)) |
| 27 | } |
| 28 | if tagIsNull(u64) { |
| 29 | *i = (*i)[n:] |
| 30 | return nil |
| 31 | } |
| 32 | end := n + tagLength(u64) |
| 33 | val := (*i)[n:end] |
| 34 | *i = (*i)[end:] |
| 35 | return Bytes(val) |
| 36 | } |
| 37 | |
| 38 | // NextTagAndBody returns the next value as a slice containing the value's |
| 39 | // undecoded tag followed by its body. NextTagAndBody panics if the next |