23 if (str.size() >= 2 && str[0] ==
'0' && (str[1] ==
'x' || str[1] ==
'X')) {
31 std::string str_copy(str.data(), str.size());
32 long result = std::strtol(str_copy.c_str(), &end, 16);
34 if (end == str_copy.c_str() || *end !=
'\0') {
37 if (result < INT_MIN || result > INT_MAX) {
41 *out =
static_cast<int>(result);
51 if (str.size() >= 2 && str[0] ==
'0' && (str[1] ==
'x' || str[1] ==
'X')) {
59 std::string str_copy(str.data(), str.size());
60 unsigned long result = std::strtoul(str_copy.c_str(), &end, 16);
62 if (end == str_copy.c_str() || *end !=
'\0') {
65 if (result > UINT32_MAX) {
69 *out =
static_cast<uint32_t
>(result);