Return the integer value of a hex character ch. Throw a protocol exception if the character is not [0-9a-f].
| 245 | // Return the integer value of a hex character ch. |
| 246 | // Throw a protocol exception if the character is not [0-9a-f]. |
| 247 | static uint8_t hexVal(uint8_t ch) { |
| 248 | if ((ch >= '0') && (ch <= '9')) { |
| 249 | return ch - '0'; |
| 250 | } else if ((ch >= 'a') && (ch <= 'f')) { |
| 251 | return ch - 'a' + 10; |
| 252 | } else { |
| 253 | throw TProtocolException(TProtocolException::INVALID_DATA, |
| 254 | "Expected hex val ([0-9a-f]); got \'" + std::string((char*)&ch, 1) |
| 255 | + "\'."); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | // Return the hex character representing the integer val. The value is masked |
| 260 | // to make sure it is in the correct range. |
no test coverage detected