MCPcopy Create free account
hub / github.com/VCVRack/Rack / stringToInt

Function stringToInt

src/string.cpp:577–589  ·  view source on GitHub ↗

Parses `s` as a positive base-10 number. Returns -1 if invalid. */

Source from the content-addressed store, hash-verified

575
576/** Parses `s` as a positive base-10 number. Returns -1 if invalid. */
577static int stringToInt(const std::string& s) {
578 if (s.empty())
579 return -1;
580
581 int i = 0;
582 for (char c : s) {
583 if (!std::isdigit((unsigned char) c))
584 return -1;
585 i *= 10;
586 i += (c - '0');
587 }
588 return i;
589}
590
591/** Returns whether version part p1 is earlier than p2. */
592static bool compareVersionPart(const std::string& p1, const std::string& p2) {

Callers 1

compareVersionPartFunction · 0.85

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected