2021-12-07 03:51:27 +03:00
|
|
|
|
2021-12-08 09:17:17 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <cstdint> // uint64_t, int64_t
|
2021-12-07 03:51:27 +03:00
|
|
|
#include <cstdlib> // strtof, strtod, strtold, strtoll, strtoull
|
|
|
|
|
|
2021-12-08 09:17:17 +03:00
|
|
|
#include <nlohmann/detail/macro_scope.hpp>
|
|
|
|
|
|
2021-12-07 03:51:27 +03:00
|
|
|
namespace nlohmann
|
|
|
|
|
{
|
|
|
|
|
namespace detail
|
|
|
|
|
{
|
2021-12-08 09:17:17 +03:00
|
|
|
|
2021-12-07 03:51:27 +03:00
|
|
|
struct numerizer
|
|
|
|
|
{
|
|
|
|
|
JSON_HEDLEY_NON_NULL(2)
|
|
|
|
|
static void strtof(float& f, const char* str, char** endptr) noexcept
|
|
|
|
|
{
|
|
|
|
|
f = std::strtof(str, endptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSON_HEDLEY_NON_NULL(2)
|
|
|
|
|
static void strtof(double& f, const char* str, char** endptr) noexcept
|
|
|
|
|
{
|
|
|
|
|
f = std::strtod(str, endptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSON_HEDLEY_NON_NULL(2)
|
|
|
|
|
static void strtof(long double& f, const char* str, char** endptr) noexcept
|
|
|
|
|
{
|
|
|
|
|
f = std::strtold(str, endptr);
|
|
|
|
|
}
|
2021-12-08 09:17:17 +03:00
|
|
|
|
2021-12-07 03:51:27 +03:00
|
|
|
JSON_HEDLEY_NON_NULL(2)
|
2021-12-08 09:17:17 +03:00
|
|
|
static uint64_t strtoull(const char* str, char** endptr, int base)
|
2021-12-07 03:51:27 +03:00
|
|
|
{
|
|
|
|
|
return std::strtoull(str, endptr, base);
|
|
|
|
|
}
|
2021-12-08 09:17:17 +03:00
|
|
|
|
2021-12-07 03:51:27 +03:00
|
|
|
JSON_HEDLEY_NON_NULL(2)
|
2021-12-08 09:17:17 +03:00
|
|
|
static int64_t strtoll(const char* str, char** endptr, int base)
|
2021-12-07 03:51:27 +03:00
|
|
|
{
|
|
|
|
|
return std::strtoll(str, endptr, base);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-12-08 09:17:17 +03:00
|
|
|
} // namespace detail
|
|
|
|
|
} // namespace nlohmann
|