ReadUint reads an unsigned integer of either 8, 16, 32 or 64 bits from r, returning the result as a uint64.
(r Reader, bits int32)
| 65 | // ReadUint reads an unsigned integer of either 8, 16, 32 or 64 bits from r, |
| 66 | // returning the result as a uint64. |
| 67 | func ReadUint(r Reader, bits int32) uint64 { |
| 68 | switch bits { |
| 69 | case 8: |
| 70 | return uint64(r.Uint8()) |
| 71 | case 16: |
| 72 | return uint64(r.Uint16()) |
| 73 | case 32: |
| 74 | return uint64(r.Uint32()) |
| 75 | case 64: |
| 76 | return r.Uint64() |
| 77 | default: |
| 78 | r.SetError(fmt.Errorf("Unsupported integer bit count %v", bits)) |
| 79 | return 0 |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // ReadInt reads a signed integer of either 8, 16, 32 or 64 bits from r, |
| 84 | // returning the result as a int64. |