mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Add str_toint64_base
To convert a string to an `int64_t`.
This commit is contained in:
parent
aea45741a0
commit
2be3ecfd4f
|
@ -3430,10 +3430,30 @@ int str_isallnum(const char *str)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int str_toint(const char *str) { return str_toint_base(str, 10); }
|
||||
int str_toint_base(const char *str, int base) { return strtol(str, NULL, base); }
|
||||
unsigned long str_toulong_base(const char *str, int base) { return strtoul(str, NULL, base); }
|
||||
float str_tofloat(const char *str) { return strtod(str, NULL); }
|
||||
int str_toint(const char *str)
|
||||
{
|
||||
return str_toint_base(str, 10);
|
||||
}
|
||||
|
||||
int str_toint_base(const char *str, int base)
|
||||
{
|
||||
return strtol(str, nullptr, base);
|
||||
}
|
||||
|
||||
unsigned long str_toulong_base(const char *str, int base)
|
||||
{
|
||||
return strtoul(str, nullptr, base);
|
||||
}
|
||||
|
||||
int64_t str_toint64_base(const char *str, int base)
|
||||
{
|
||||
return strtoll(str, nullptr, base);
|
||||
}
|
||||
|
||||
float str_tofloat(const char *str)
|
||||
{
|
||||
return strtod(str, nullptr);
|
||||
}
|
||||
|
||||
int str_utf8_comp_nocase(const char *a, const char *b)
|
||||
{
|
||||
|
|
|
@ -2133,6 +2133,7 @@ void net_stats(NETSTATS *stats);
|
|||
int str_toint(const char *str);
|
||||
int str_toint_base(const char *str, int base);
|
||||
unsigned long str_toulong_base(const char *str, int base);
|
||||
int64_t str_toint64_base(const char *str, int base = 10);
|
||||
float str_tofloat(const char *str);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue