Bug fixing.

This commit is contained in:
Your Name
2025-04-25 20:31:25 +12:00
parent f73e6f1ac5
commit d0b7c27af3
6 changed files with 30 additions and 95 deletions

View File

@@ -129,5 +129,14 @@ std::vector<std::string> string2multi(std::string values)
return result;
}
int str2int(const std::string &str)
{
try {
return std::stoi(str);
} catch (const std::exception& e) {
std::cerr << "Error: Invalid integer string: [" << str << "]" << std::endl;
return 0;
}
}
} // namespace dropshell

View File

@@ -22,5 +22,6 @@ std::string quote(std::string str);
std::string multi2string(std::vector<std::string> values);
std::vector<std::string> string2multi(std::string values);
int str2int(const std::string & str);
} // namespace dropshell