Run 'make almalgamate'
astyle reformatted some stuff... I... don't know why.
This commit is contained in:
parent
e830bc502f
commit
fe90fa5181
@ -196,7 +196,7 @@ boundaries compute_boundaries(FloatType value)
|
|||||||
constexpr int kMinExp = 1 - kBias;
|
constexpr int kMinExp = 1 - kBias;
|
||||||
constexpr uint64_t kHiddenBit = uint64_t{1} << (kPrecision - 1); // = 2^(p-1)
|
constexpr uint64_t kHiddenBit = uint64_t{1} << (kPrecision - 1); // = 2^(p-1)
|
||||||
|
|
||||||
using bits_type = typename std::conditional< kPrecision == 24, uint32_t, uint64_t >::type;
|
using bits_type = typename std::conditional<kPrecision == 24, uint32_t, uint64_t>::type;
|
||||||
|
|
||||||
const uint64_t bits = reinterpret_bits<bits_type>(value);
|
const uint64_t bits = reinterpret_bits<bits_type>(value);
|
||||||
const uint64_t E = bits >> (kPrecision - 1);
|
const uint64_t E = bits >> (kPrecision - 1);
|
||||||
@ -607,7 +607,10 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
|
|||||||
// = ((p1 ) * 2^-e + (p2 )) * 2^e
|
// = ((p1 ) * 2^-e + (p2 )) * 2^e
|
||||||
// = p1 + p2 * 2^e
|
// = p1 + p2 * 2^e
|
||||||
|
|
||||||
const diyfp one(uint64_t{1} << -M_plus.e, M_plus.e);
|
const diyfp one(uint64_t
|
||||||
|
{
|
||||||
|
1
|
||||||
|
} << -M_plus.e, M_plus.e);
|
||||||
|
|
||||||
uint32_t p1 = static_cast<uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
|
uint32_t p1 = static_cast<uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
|
||||||
uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e
|
uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e
|
||||||
|
|||||||
@ -414,7 +414,7 @@ class serializer
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// we finish reading, but do not accept: string was incomplete
|
// we finish reading, but do not accept: string was incomplete
|
||||||
std::string sn(3,'\0');
|
std::string sn(3, '\0');
|
||||||
snprintf(&sn[0], sn.size(), "%.2X", static_cast<uint8_t>(s.back()));
|
snprintf(&sn[0], sn.size(), "%.2X", static_cast<uint8_t>(s.back()));
|
||||||
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn));
|
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7667,7 +7667,7 @@ struct hash<nlohmann::json>
|
|||||||
/// @note: do not remove the space after '<',
|
/// @note: do not remove the space after '<',
|
||||||
/// see https://github.com/nlohmann/json/pull/679
|
/// see https://github.com/nlohmann/json/pull/679
|
||||||
template<>
|
template<>
|
||||||
struct less< ::nlohmann::detail::value_t>
|
struct less<::nlohmann::detail::value_t>
|
||||||
{
|
{
|
||||||
/*!
|
/*!
|
||||||
@brief compare two value_t enum values
|
@brief compare two value_t enum values
|
||||||
|
|||||||
@ -1973,10 +1973,8 @@ class input_adapter
|
|||||||
#include <clocale> // localeconv
|
#include <clocale> // localeconv
|
||||||
#include <cstddef> // size_t
|
#include <cstddef> // size_t
|
||||||
#include <cstdlib> // strtof, strtod, strtold, strtoll, strtoull
|
#include <cstdlib> // strtof, strtod, strtold, strtoll, strtoull
|
||||||
|
#include <cstdio> // snprintf
|
||||||
#include <initializer_list> // initializer_list
|
#include <initializer_list> // initializer_list
|
||||||
#include <ios> // hex, uppercase
|
|
||||||
#include <iomanip> // setw, setfill
|
|
||||||
#include <sstream> // stringstream
|
|
||||||
#include <string> // char_traits, string
|
#include <string> // char_traits, string
|
||||||
#include <vector> // vector
|
#include <vector> // vector
|
||||||
|
|
||||||
@ -3146,10 +3144,9 @@ scan_number_done:
|
|||||||
if ('\x00' <= c and c <= '\x1F')
|
if ('\x00' <= c and c <= '\x1F')
|
||||||
{
|
{
|
||||||
// escape control characters
|
// escape control characters
|
||||||
std::stringstream ss;
|
char cs[9];
|
||||||
ss << "<U+" << std::setw(4) << std::uppercase << std::setfill('0')
|
snprintf(cs, 9, "<U+%.4X>", c);
|
||||||
<< std::hex << static_cast<int>(c) << ">";
|
result += cs;
|
||||||
result += ss.str();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -5619,12 +5616,10 @@ class output_adapter
|
|||||||
#include <cmath> // ldexp
|
#include <cmath> // ldexp
|
||||||
#include <cstddef> // size_t
|
#include <cstddef> // size_t
|
||||||
#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
|
#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
|
||||||
|
#include <cstdio> // snprintf
|
||||||
#include <cstring> // memcpy
|
#include <cstring> // memcpy
|
||||||
#include <iomanip> // setw, setfill
|
|
||||||
#include <ios> // hex
|
|
||||||
#include <iterator> // back_inserter
|
#include <iterator> // back_inserter
|
||||||
#include <limits> // numeric_limits
|
#include <limits> // numeric_limits
|
||||||
#include <sstream> // stringstream
|
|
||||||
#include <string> // char_traits, string
|
#include <string> // char_traits, string
|
||||||
#include <utility> // make_pair, move
|
#include <utility> // make_pair, move
|
||||||
|
|
||||||
@ -7283,9 +7278,9 @@ class binary_reader
|
|||||||
*/
|
*/
|
||||||
std::string get_token_string() const
|
std::string get_token_string() const
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
char cr[3];
|
||||||
ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << current;
|
snprintf(cr, 3, "%.2X", current);
|
||||||
return ss.str();
|
return std::string{cr};
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -8272,11 +8267,8 @@ class binary_writer
|
|||||||
#include <cstddef> // size_t, ptrdiff_t
|
#include <cstddef> // size_t, ptrdiff_t
|
||||||
#include <cstdint> // uint8_t
|
#include <cstdint> // uint8_t
|
||||||
#include <cstdio> // snprintf
|
#include <cstdio> // snprintf
|
||||||
#include <iomanip> // setfill
|
|
||||||
#include <iterator> // next
|
|
||||||
#include <limits> // numeric_limits
|
#include <limits> // numeric_limits
|
||||||
#include <string> // string
|
#include <string> // string
|
||||||
#include <sstream> // stringstream
|
|
||||||
#include <type_traits> // is_same
|
#include <type_traits> // is_same
|
||||||
|
|
||||||
// #include <nlohmann/detail/exceptions.hpp>
|
// #include <nlohmann/detail/exceptions.hpp>
|
||||||
@ -8480,7 +8472,7 @@ boundaries compute_boundaries(FloatType value)
|
|||||||
constexpr int kMinExp = 1 - kBias;
|
constexpr int kMinExp = 1 - kBias;
|
||||||
constexpr uint64_t kHiddenBit = uint64_t{1} << (kPrecision - 1); // = 2^(p-1)
|
constexpr uint64_t kHiddenBit = uint64_t{1} << (kPrecision - 1); // = 2^(p-1)
|
||||||
|
|
||||||
using bits_type = typename std::conditional< kPrecision == 24, uint32_t, uint64_t >::type;
|
using bits_type = typename std::conditional<kPrecision == 24, uint32_t, uint64_t>::type;
|
||||||
|
|
||||||
const uint64_t bits = reinterpret_bits<bits_type>(value);
|
const uint64_t bits = reinterpret_bits<bits_type>(value);
|
||||||
const uint64_t E = bits >> (kPrecision - 1);
|
const uint64_t E = bits >> (kPrecision - 1);
|
||||||
@ -8891,7 +8883,10 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
|
|||||||
// = ((p1 ) * 2^-e + (p2 )) * 2^e
|
// = ((p1 ) * 2^-e + (p2 )) * 2^e
|
||||||
// = p1 + p2 * 2^e
|
// = p1 + p2 * 2^e
|
||||||
|
|
||||||
const diyfp one(uint64_t{1} << -M_plus.e, M_plus.e);
|
const diyfp one(uint64_t
|
||||||
|
{
|
||||||
|
1
|
||||||
|
} << -M_plus.e, M_plus.e);
|
||||||
|
|
||||||
uint32_t p1 = static_cast<uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
|
uint32_t p1 = static_cast<uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
|
||||||
uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e
|
uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e
|
||||||
@ -9753,9 +9748,9 @@ class serializer
|
|||||||
|
|
||||||
case UTF8_REJECT: // decode found invalid UTF-8 byte
|
case UTF8_REJECT: // decode found invalid UTF-8 byte
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::string sn(3, '\0');
|
||||||
ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << static_cast<int>(byte);
|
snprintf(&sn[0], sn.size(), "%.2X", byte);
|
||||||
JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + ss.str()));
|
JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn));
|
||||||
}
|
}
|
||||||
|
|
||||||
default: // decode found yet incomplete multi-byte code point
|
default: // decode found yet incomplete multi-byte code point
|
||||||
@ -9781,9 +9776,9 @@ class serializer
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// we finish reading, but do not accept: string was incomplete
|
// we finish reading, but do not accept: string was incomplete
|
||||||
std::stringstream ss;
|
std::string sn(3, '\0');
|
||||||
ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << static_cast<int>(static_cast<uint8_t>(s.back()));
|
snprintf(&sn[0], sn.size(), "%.2X", static_cast<uint8_t>(s.back()));
|
||||||
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + ss.str()));
|
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18411,7 +18406,7 @@ struct hash<nlohmann::json>
|
|||||||
/// @note: do not remove the space after '<',
|
/// @note: do not remove the space after '<',
|
||||||
/// see https://github.com/nlohmann/json/pull/679
|
/// see https://github.com/nlohmann/json/pull/679
|
||||||
template<>
|
template<>
|
||||||
struct less< ::nlohmann::detail::value_t>
|
struct less<::nlohmann::detail::value_t>
|
||||||
{
|
{
|
||||||
/*!
|
/*!
|
||||||
@brief compare two value_t enum values
|
@brief compare two value_t enum values
|
||||||
|
|||||||
@ -1093,9 +1093,9 @@ TEST_CASE("value conversion")
|
|||||||
|
|
||||||
SECTION("superfluous entries")
|
SECTION("superfluous entries")
|
||||||
{
|
{
|
||||||
json j8 = {{0, 1, 2}, {1, 2, 3}, {2, 3, 4}};
|
json j8 = {{0, 1, 2}, {1, 2, 3}, {2, 3, 4}};
|
||||||
m2 = j8.get<std::map<int, int>>();
|
m2 = j8.get<std::map<int, int>>();
|
||||||
CHECK(m == m2);
|
CHECK(m == m2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -317,8 +317,8 @@ TEST_CASE("object inspection")
|
|||||||
SECTION("round trips")
|
SECTION("round trips")
|
||||||
{
|
{
|
||||||
for (const auto& s :
|
for (const auto& s :
|
||||||
{"3.141592653589793", "1000000000000000010E5"
|
{"3.141592653589793", "1000000000000000010E5"
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
json j1 = json::parse(s);
|
json j1 = json::parse(s);
|
||||||
std::string s1 = j1.dump();
|
std::string s1 = j1.dump();
|
||||||
|
|||||||
@ -45,19 +45,19 @@ void from_json(const json&, pod) noexcept;
|
|||||||
void from_json(const json&, pod_bis);
|
void from_json(const json&, pod_bis);
|
||||||
static json j;
|
static json j;
|
||||||
|
|
||||||
static_assert(noexcept(json{}), "");
|
static_assert(noexcept(json {}), "");
|
||||||
static_assert(noexcept(nlohmann::to_json(j, 2)), "");
|
static_assert(noexcept(nlohmann::to_json(j, 2)), "");
|
||||||
static_assert(noexcept(nlohmann::to_json(j, 2.5)), "");
|
static_assert(noexcept(nlohmann::to_json(j, 2.5)), "");
|
||||||
static_assert(noexcept(nlohmann::to_json(j, true)), "");
|
static_assert(noexcept(nlohmann::to_json(j, true)), "");
|
||||||
static_assert(noexcept(nlohmann::to_json(j, test{})), "");
|
static_assert(noexcept(nlohmann::to_json(j, test {})), "");
|
||||||
static_assert(noexcept(nlohmann::to_json(j, pod{})), "");
|
static_assert(noexcept(nlohmann::to_json(j, pod {})), "");
|
||||||
static_assert(not noexcept(nlohmann::to_json(j, pod_bis{})), "");
|
static_assert(not noexcept(nlohmann::to_json(j, pod_bis {})), "");
|
||||||
static_assert(noexcept(json(2)), "");
|
static_assert(noexcept(json(2)), "");
|
||||||
static_assert(noexcept(json(test{})), "");
|
static_assert(noexcept(json(test {})), "");
|
||||||
static_assert(noexcept(json(pod{})), "");
|
static_assert(noexcept(json(pod {})), "");
|
||||||
static_assert(noexcept(j.get<pod>()), "");
|
static_assert(noexcept(j.get<pod>()), "");
|
||||||
static_assert(not noexcept(j.get<pod_bis>()), "");
|
static_assert(not noexcept(j.get<pod_bis>()), "");
|
||||||
static_assert(noexcept(json(pod{})), "");
|
static_assert(noexcept(json(pod {})), "");
|
||||||
|
|
||||||
TEST_CASE("runtime checks")
|
TEST_CASE("runtime checks")
|
||||||
{
|
{
|
||||||
|
|||||||
@ -585,7 +585,7 @@ struct pod_serializer
|
|||||||
std::is_pod<U>::value and std::is_class<U>::value, int>::type = 0>
|
std::is_pod<U>::value and std::is_class<U>::value, int>::type = 0>
|
||||||
static void to_json(BasicJsonType& j, const T& t) noexcept
|
static void to_json(BasicJsonType& j, const T& t) noexcept
|
||||||
{
|
{
|
||||||
auto bytes = static_cast< const unsigned char*>(static_cast<const void*>(&t));
|
auto bytes = static_cast<const unsigned char*>(static_cast<const void*>(&t));
|
||||||
std::uint64_t value = bytes[0];
|
std::uint64_t value = bytes[0];
|
||||||
for (auto i = 1; i < 8; ++i)
|
for (auto i = 1; i < 8; ++i)
|
||||||
value |= std::uint64_t{bytes[i]} << 8 * i;
|
value |= std::uint64_t{bytes[i]} << 8 * i;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user