| 140 | } |
| 141 | |
| 142 | inline bool ScannerContext::Stream::ReadVLong(int64_t* value, Status* status) { |
| 143 | int8_t* firstbyte; |
| 144 | uint8_t* bytes; |
| 145 | |
| 146 | RETURN_IF_FALSE(ReadBytes(1, reinterpret_cast<uint8_t**>(&firstbyte), status)); |
| 147 | |
| 148 | int len = ReadWriteUtil::DecodeVIntSize(*firstbyte); |
| 149 | bool is_negative = ReadWriteUtil::IsNegativeVInt(*firstbyte); |
| 150 | if (len > ReadWriteUtil::MAX_VINT_LEN) { |
| 151 | *status = Status("ReadVLong: size is too big"); |
| 152 | return false; |
| 153 | } |
| 154 | |
| 155 | if (len == 1) { |
| 156 | *value = static_cast<int64_t>(*firstbyte); |
| 157 | return true; |
| 158 | } |
| 159 | --len; |
| 160 | |
| 161 | RETURN_IF_FALSE(ReadBytes(len, &bytes, status)); |
| 162 | |
| 163 | *value = 0; |
| 164 | |
| 165 | for (int i = 0; i < len; i++) { |
| 166 | *value = (*value << 8) | (bytes[i] & 0xFF); |
| 167 | } |
| 168 | |
| 169 | if (is_negative) *value = *value ^ (static_cast<int64_t>(-1)); |
| 170 | |
| 171 | return true; |
| 172 | } |
| 173 | |
| 174 | inline bool ScannerContext::Stream::ReadZLong(int64_t* value, Status* status) { |
| 175 | uint8_t* bytes; |
no test coverage detected