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

Method is_valid_float

core/string/ustring.cpp:5057–5095  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5055}
5056
5057bool String::is_valid_float() const {
5058 int len = length();
5059
5060 if (len == 0) {
5061 return false;
5062 }
5063
5064 int from = 0;
5065 if (operator[](0) == '+' || operator[](0) == '-') {
5066 from++;
5067 }
5068
5069 bool exponent_found = false;
5070 bool period_found = false;
5071 bool sign_found = false;
5072 bool exponent_values_found = false;
5073 bool numbers_found = false;
5074
5075 for (int i = from; i < len; i++) {
5076 const char32_t c = operator[](i);
5077 if (is_digit(c)) {
5078 if (exponent_found) {
5079 exponent_values_found = true;
5080 } else {
5081 numbers_found = true;
5082 }
5083 } else if (numbers_found && !exponent_found && (c == 'e' || c == 'E')) {
5084 exponent_found = true;
5085 } else if (!period_found && !exponent_found && c == '.') {
5086 period_found = true;
5087 } else if ((c == '-' || c == '+') && exponent_found && !exponent_values_found && !sign_found) {
5088 sign_found = true;
5089 } else {
5090 return false; // no start with number plz
5091 }
5092 }
5093
5094 return numbers_found;
5095}
5096
5097String String::path_to_file(const String &p_path) const {
5098 // Don't get base dir for src, this is expected to be a dir already.

Callers 6

compare_dict_arrayFunction · 0.80
ConfigMethod · 0.80
_inline_object_parseMethod · 0.80
_parse_range_hintFunction · 0.80
test_string.hFile · 0.80
_get_tokenMethod · 0.80

Calls 1

is_digitFunction · 0.85

Tested by

no test coverage detected