config/Parser: use std::size_t
This commit is contained in:
parent
ab318200db
commit
d64729065e
|
@ -70,28 +70,28 @@ ParsePositive(const char *s)
|
|||
return (unsigned)value;
|
||||
}
|
||||
|
||||
template<size_t OPERAND>
|
||||
static size_t
|
||||
Multiply(size_t value)
|
||||
template<std::size_t OPERAND>
|
||||
static std::size_t
|
||||
Multiply(std::size_t value)
|
||||
{
|
||||
static constexpr size_t MAX_VALUE = SIZE_MAX / OPERAND;
|
||||
static constexpr std::size_t MAX_VALUE = SIZE_MAX / OPERAND;
|
||||
if (value > MAX_VALUE)
|
||||
throw std::runtime_error("Value too large");
|
||||
|
||||
return value * OPERAND;
|
||||
}
|
||||
|
||||
size_t
|
||||
ParseSize(const char *s, size_t default_factor)
|
||||
std::size_t
|
||||
ParseSize(const char *s, std::size_t default_factor)
|
||||
{
|
||||
char *endptr;
|
||||
size_t value = strtoul(s, &endptr, 10);
|
||||
std::size_t value = strtoul(s, &endptr, 10);
|
||||
if (endptr == s)
|
||||
throw std::runtime_error("Failed to parse integer");
|
||||
|
||||
static constexpr size_t KILO = 1024;
|
||||
static constexpr size_t MEGA = 1024 * KILO;
|
||||
static constexpr size_t GIGA = 1024 * MEGA;
|
||||
static constexpr std::size_t KILO = 1024;
|
||||
static constexpr std::size_t MEGA = 1024 * KILO;
|
||||
static constexpr std::size_t GIGA = 1024 * MEGA;
|
||||
|
||||
s = StripLeft(endptr);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ ParsePositive(const char *s);
|
|||
*
|
||||
* Throws on error.
|
||||
*/
|
||||
size_t
|
||||
ParseSize(const char *s, size_t default_factor=1);
|
||||
std::size_t
|
||||
ParseSize(const char *s, std::size_t default_factor=1);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue