Parse a signed variable length encoded integer from the byte stream. A signed varint is encoded as a normal varint with zigzag encoding applied, i.e. the low bit of the value is used to indicate the sign.
| 116 | /// signed varint is encoded as a normal varint with zigzag encoding applied, |
| 117 | /// i.e. the low bit of the value is used to indicate the sign. |
| 118 | LogicalResult readSignedVarInt(uint64_t &result) { |
| 119 | if (failed(readVarInt(result))) |
| 120 | return failure(); |
| 121 | // Essentially (but using unsigned): (x >> 1) ^ -(x & 1). |
| 122 | result = (result >> 1) ^ (~(result & 1) + 1); |
| 123 | return success(); |
| 124 | } |
| 125 | |
| 126 | template <typename T> |
| 127 | std::enable_if_t<std::is_integral<T>::value, LogicalResult> readLE(T &value) { |
no outgoing calls
no test coverage detected