TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ diagnostics()

template<typename BasicJsonType >
static std::string nlohmann::detail::exception::diagnostics ( const BasicJsonType &  leaf_element)
inlinestaticprotected

Definition at line 2671 of file json.hpp.

2672 {
2673#if JSON_DIAGNOSTICS
2674 std::vector<std::string> tokens;
2675
2676 for (const auto *current = &leaf_element; current->m_parent != nullptr; current = current->m_parent)
2677 {
2678 switch (current->m_parent->type())
2679 {
2680 case value_t::array:
2681 {
2682 for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
2683 {
2684 if (&current->m_parent->m_value.array->operator[](i) == current)
2685 {
2686 tokens.emplace_back(std::to_string(i));
2687 break;
2688 }
2689 }
2690
2691 break;
2692 }
2693
2694 case value_t::object:
2695 {
2696 for (const auto &element : *current->m_parent->m_value.object)
2697 {
2698 if (&element.second == current)
2699 {
2700 tokens.emplace_back(element.first.c_str());
2701 break;
2702 }
2703 }
2704
2705 break;
2706 }
2707
2708 case value_t::null: // LCOV_EXCL_LINE
2709 case value_t::string: // LCOV_EXCL_LINE
2710 case value_t::boolean: // LCOV_EXCL_LINE
2711 case value_t::number_integer: // LCOV_EXCL_LINE
2712 case value_t::number_unsigned: // LCOV_EXCL_LINE
2713 case value_t::number_float: // LCOV_EXCL_LINE
2714 case value_t::binary: // LCOV_EXCL_LINE
2715 case value_t::discarded: // LCOV_EXCL_LINE
2716 default: // LCOV_EXCL_LINE
2717 break; // LCOV_EXCL_LINE
2718 }
2719 }
2720
2721 if (tokens.empty())
2722 {
2723 return "";
2724 }
2725
2726 return "(" + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
2727 [](const std::string & a, const std::string & b)
2728 {
2729 return a + "/" + detail::escape(b);
2730 }) + ") ";
2731#else
2732 static_cast<void>(leaf_element);
2733 return "";
2734#endif
2735 }
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)