MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / is_valid_hex_number

Method is_valid_hex_number

core/string/ustring.cpp:5020–5055  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5018}
5019
5020bool String::is_valid_hex_number(bool p_with_prefix) const {
5021 int len = length();
5022
5023 if (len == 0) {
5024 return false;
5025 }
5026
5027 int from = 0;
5028 if (len != 1 && (operator[](0) == '+' || operator[](0) == '-')) {
5029 from++;
5030 }
5031
5032 if (p_with_prefix) {
5033 if (len < 3) {
5034 return false;
5035 }
5036 if (operator[](from) != '0' || operator[](from + 1) != 'x') {
5037 return false;
5038 }
5039 from += 2;
5040 }
5041
5042 if (from == len) {
5043 return false;
5044 }
5045
5046 for (int i = from; i < len; i++) {
5047 char32_t c = operator[](i);
5048 if (is_hex_digit(c)) {
5049 continue;
5050 }
5051 return false;
5052 }
5053
5054 return true;
5055}
5056
5057bool String::is_valid_float() const {
5058 int len = length();

Callers 7

_html_submittedMethod · 0.80
pck_startMethod · 0.80
is_valid_ip_addressMethod · 0.80
_inline_object_parseMethod · 0.80
test_string.hFile · 0.80
_get_tokenMethod · 0.80

Calls 1

is_hex_digitFunction · 0.85

Tested by

no test coverage detected