2022-03-05 12:44:06 +02:00
|
|
|
/*----- atoi function -----*/
|
|
|
|
inline bool str_to_number (bool& out, const char *in)
|
|
|
|
{
|
|
|
|
if (0==in || 0==in[0]) return false;
|
|
|
|
|
|
|
|
out = (strtol(in, NULL, 10) != 0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool str_to_number (char& out, const char *in)
|
|
|
|
{
|
|
|
|
if (0==in || 0==in[0]) return false;
|
|
|
|
|
|
|
|
out = (char) strtol(in, NULL, 10);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool str_to_number (unsigned char& out, const char *in)
|
|
|
|
{
|
|
|
|
if (0==in || 0==in[0]) return false;
|
|
|
|
|
|
|
|
out = (unsigned char) strtoul(in, NULL, 10);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool str_to_number (short& out, const char *in)
|
|
|
|
{
|
|
|
|
if (0==in || 0==in[0]) return false;
|
|
|
|
|
|
|
|
out = (short) strtol(in, NULL, 10);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool str_to_number (unsigned short& out, const char *in)
|
|
|
|
{
|
|
|
|
if (0==in || 0==in[0]) return false;
|
|
|
|
|
|
|
|
out = (unsigned short) strtoul(in, NULL, 10);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool str_to_number (int& out, const char *in)
|
|
|
|
{
|
|
|
|
if (0==in || 0==in[0]) return false;
|
|
|
|
|
|
|
|
out = (int) strtol(in, NULL, 10);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool str_to_number (unsigned int& out, const char *in)
|
|
|
|
{
|
|
|
|
if (0==in || 0==in[0]) return false;
|
|
|
|
|
|
|
|
out = (unsigned int) strtoul(in, NULL, 10);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-03-12 11:39:41 +02:00
|
|
|
inline bool str_to_number (int64_t& out, const char *in)
|
2022-03-05 12:44:06 +02:00
|
|
|
{
|
|
|
|
if (0==in || 0==in[0]) return false;
|
|
|
|
|
2022-03-12 11:39:41 +02:00
|
|
|
out = (int64_t) strtoull(in, NULL, 10);
|
2022-03-05 12:44:06 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool str_to_number (float& out, const char *in)
|
|
|
|
{
|
|
|
|
if (0==in || 0==in[0]) return false;
|
|
|
|
|
|
|
|
out = (float) strtof(in, NULL);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----- atoi function -----*/
|