| 5055 | } |
| 5056 | |
| 5057 | bool 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 | |
| 5097 | String 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. |
no test coverage detected