MCPcopy Create free account
hub / github.com/apache/trafficserver / ParseHex

Function ParseHex

lib/yamlcpp/src/exp.cpp:13–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11namespace YAML {
12namespace Exp {
13unsigned ParseHex(const std::string& str, const Mark& mark) {
14 unsigned value = 0;
15 for (char ch : str) {
16 int digit = 0;
17 if ('a' <= ch && ch <= 'f')
18 digit = ch - 'a' + 10;
19 else if ('A' <= ch && ch <= 'F')
20 digit = ch - 'A' + 10;
21 else if ('0' <= ch && ch <= '9')
22 digit = ch - '0';
23 else
24 throw ParserException(mark, ErrorMsg::INVALID_HEX);
25
26 value = (value << 4) + digit;
27 }
28
29 return value;
30}
31
32std::string Str(unsigned ch) { return std::string(1, static_cast<char>(ch)); }
33

Callers 1

EscapeFunction · 0.85

Calls 1

ParserExceptionFunction · 0.85

Tested by

no test coverage detected