libluna: Allow passing a base to scan_(un)signed_integer()
This commit is contained in:
parent
8c2348c425
commit
a2c081f219
@ -2,10 +2,10 @@
|
|||||||
#include <luna/Types.h>
|
#include <luna/Types.h>
|
||||||
|
|
||||||
// Parse an unsigned integer and advance *str to point to the first non-digit character after the number.
|
// Parse an unsigned integer and advance *str to point to the first non-digit character after the number.
|
||||||
usize scan_unsigned_integer(const char** str);
|
usize scan_unsigned_integer(const char** str, int base = 10);
|
||||||
|
|
||||||
// Parse a signed integer and advance *str to point to the first non-digit character after the number.
|
// Parse a signed integer and advance *str to point to the first non-digit character after the number.
|
||||||
isize scan_signed_integer(const char** str);
|
isize scan_signed_integer(const char** str, int base = 10);
|
||||||
|
|
||||||
// Parse an unsigned integer, similar to strtoull().
|
// Parse an unsigned integer, similar to strtoull().
|
||||||
usize parse_unsigned_integer(const char* str, const char** endptr, int base);
|
usize parse_unsigned_integer(const char* str, const char** endptr, int base);
|
||||||
|
@ -89,12 +89,12 @@ isize parse_signed_integer(const char* str, const char** endptr, int base)
|
|||||||
return negative ? -(isize)rc : (isize)rc;
|
return negative ? -(isize)rc : (isize)rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
usize scan_unsigned_integer(const char** str)
|
usize scan_unsigned_integer(const char** str, int base)
|
||||||
{
|
{
|
||||||
return parse_unsigned_integer(*str, str, 10);
|
return parse_unsigned_integer(*str, str, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
isize scan_signed_integer(const char** str)
|
isize scan_signed_integer(const char** str, int base)
|
||||||
{
|
{
|
||||||
return parse_signed_integer(*str, str, 10);
|
return parse_signed_integer(*str, str, base);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user