MCPcopy Create free account
hub / github.com/apache/thrift / hexVal

Function hexVal

lib/cpp/src/thrift/protocol/TJSONProtocol.cpp:247–257  ·  view source on GitHub ↗

Return the integer value of a hex character ch. Throw a protocol exception if the character is not [0-9a-f].

Source from the content-addressed store, hash-verified

245// Return the integer value of a hex character ch.
246// Throw a protocol exception if the character is not [0-9a-f].
247static 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.

Callers 1

readJSONEscapeCharMethod · 0.85

Calls 2

stringFunction · 0.85
TProtocolExceptionClass · 0.70

Tested by

no test coverage detected