♻️ move diagnostic code in header

This commit is contained in:
Niels Lohmann committed 2021-01-09 19:21:18 +01:00
1 parent 43cd5c8a4d
commit e160749003
13 files changed
+748 -548

No files matched your search

@@ -8,6 +8,7 @@
#include <string> // string
#include <cmath> // isnan, isinf
#include <nlohmann/detail/diagnostics_t.hpp>
#include <nlohmann/detail/input/binary_reader.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/output/output_adapters.hpp>
@@ -57,7 +58,7 @@ class binary_writer
default:
{
JSON_THROW(type_error::create(317, j.diagnostics() + "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name())));
JSON_THROW(type_error::create(317, "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name()), detail::diagnostics_t<BasicJsonType>(j)));;
}
}
}
@@ -906,8 +907,7 @@ class binary_writer
const auto it = name.find(static_cast<typename string_t::value_type>(0));
if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos))
{
JSON_THROW(out_of_range::create(409, j.diagnostics() +
"BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")"));
JSON_THROW(out_of_range::create(409, "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")", detail::diagnostics_t<BasicJsonType>(j)));
}
return /*id*/ 1ul + name.size() + /*zero-terminator*/1u;
@@ -1031,7 +1031,7 @@ class binary_writer
}
else
{
JSON_THROW(out_of_range::create(407, j.diagnostics() + "integer number " + std::to_string(j.m_value.number_unsigned) + " cannot be represented by BSON as it does not fit int64"));
JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(j.m_value.number_unsigned) + " cannot be represented by BSON as it does not fit int64", detail::diagnostics_t<BasicJsonType>(j)));
}
}