Parses `s` as a positive base-10 number. Returns -1 if invalid. */
| 575 | |
| 576 | /** Parses `s` as a positive base-10 number. Returns -1 if invalid. */ |
| 577 | static 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. */ |
| 592 | static bool compareVersionPart(const std::string& p1, const std::string& p2) { |
no test coverage detected