2 #include <bzscore/string.h>
4 namespace GDBServerFoundation
9 const char hexTable[17] =
"0123456789abcdef";
12 static inline unsigned hexToInt(
char hexChar)
15 if (hexChar >=
'0' && hexChar <=
'9')
17 if (hexChar >=
'A' && hexChar <=
'F')
18 return hexChar + 0x0A -
'A';
19 if (hexChar >=
'a' && hexChar <=
'f')
20 return hexChar + 0x0A -
'a';
25 static inline unsigned ParseHexValue(
const char *p)
27 return (hexToInt(p[0]) << 4) | hexToInt(p[1]);
31 static inline unsigned ParseHexValue(
char firstChar,
char secondChar)
33 return (hexToInt(firstChar) << 4) | hexToInt(secondChar);
37 template<
typename _Type>
static inline _Type ParseHexString(
const BazisLib::TempStringA &str)
42 if (!str.empty() && str[0] ==
'-')
45 for (;i < str.size(); i++)
46 result = (result << 4) | hexToInt(str[i]);