MCPcopy Create free account
hub / github.com/avast/retdec / isNumber

Function isNumber

src/utils/string.cpp:899–913  ·  view source on GitHub ↗

* @brief Checks if the string is a number. */

Source from the content-addressed store, hash-verified

897* @brief Checks if the string is a number.
898*/
899bool isNumber(const std::string &str) {
900 if (str.length() < 1)
901 return false;
902
903 unsigned k = 0;
904 if (str[0] == '-' || str[0] == '+')
905 k++;
906
907 for (unsigned i = k; i < str.length(); i++) {
908 if (!isdigit(static_cast<unsigned char>(str[i])))
909 return false;
910 }
911
912 return true;
913}
914
915/**
916 * @brief Checks if the string is a valid C language identifier.

Callers 1

TEST_FFunction · 0.85

Calls 1

lengthMethod · 0.80

Tested by 1

TEST_FFunction · 0.68