Utils::strtol only used in the app

This commit is contained in:
Luis Díaz Más
2022-02-14 20:12:46 +01:00
committed by Luis Diaz
parent 8c6e22e6aa
commit 7c6a7aefc2
7 changed files with 41 additions and 19 deletions
+22
View File
@@ -0,0 +1,22 @@
#include "utils.hpp"
#include <cstdlib>
#include <climits>
namespace Util
{
bool strtol(const char* nptr, long& n)
{
if (!nptr || *nptr == '\0')
return false;
char* endptr = nullptr;
long tmp = std::strtol(nptr, &endptr, 10);
if (*endptr != '\0')
return false;
if (tmp == LONG_MAX || tmp == LONG_MIN)
return false;
n = tmp;
return true;
}
} // namespace Util