| 177 | } |
| 178 | |
| 179 | int32_t CodedInputData::readRawVarint32() { |
| 180 | int8_t tmp = this->readRawByte(); |
| 181 | if (tmp >= 0) { |
| 182 | return tmp; |
| 183 | } |
| 184 | int32_t result = tmp & 0x7f; |
| 185 | if ((tmp = this->readRawByte()) >= 0) { |
| 186 | result |= tmp << 7; |
| 187 | } else { |
| 188 | result |= (tmp & 0x7f) << 7; |
| 189 | if ((tmp = this->readRawByte()) >= 0) { |
| 190 | result |= tmp << 14; |
| 191 | } else { |
| 192 | result |= (tmp & 0x7f) << 14; |
| 193 | if ((tmp = this->readRawByte()) >= 0) { |
| 194 | result |= tmp << 21; |
| 195 | } else { |
| 196 | result |= (tmp & 0x7f) << 21; |
| 197 | result |= (tmp = this->readRawByte()) << 28; |
| 198 | if (tmp < 0) { |
| 199 | // discard upper 32 bits |
| 200 | for (int i = 0; i < 5; i++) { |
| 201 | if (this->readRawByte() >= 0) { |
| 202 | return result; |
| 203 | } |
| 204 | } |
| 205 | throw invalid_argument("InvalidProtocolBuffer malformed varint32"); |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | return result; |
| 211 | } |
| 212 | |
| 213 | int32_t CodedInputData::readRawLittleEndian32() { |
| 214 | int8_t b1 = this->readRawByte(); |
no test coverage detected