mirror of
https://github.com/nlohmann/json.git
synced 2026-10-24 14:58:54 +00:00
Merge develop into #5901 and fix clang-tidy else-after-return
Resolve the json_sax.hpp conflicts (keep the shared error state next to the object key index; the binary parser uses the shared error state as well) and drop the else after return in the diff stack-frame code. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
28 files changed
+4848
-804
No files matched your search
@@ -147,20 +147,21 @@ class view_item
|
||||
|
||||
view_item(const iterator& it, std::size_t index)
|
||||
: m_it(it)
|
||||
{
|
||||
if (!it.is_object_iterator())
|
||||
{
|
||||
m_index = std::to_string(index);
|
||||
}
|
||||
}
|
||||
, m_position(index)
|
||||
{}
|
||||
|
||||
/// the member key, or the element index for arrays
|
||||
/// the member key, or the element index for arrays (as text made on the
|
||||
/// first call, so that iterating over the values pays nothing for it)
|
||||
string_view_t key() const
|
||||
{
|
||||
if (m_it.is_object_iterator())
|
||||
{
|
||||
return m_it.key();
|
||||
}
|
||||
if (m_index.empty())
|
||||
{
|
||||
m_index = std::to_string(m_position);
|
||||
}
|
||||
return string_view_t(m_index.data(), m_index.size());
|
||||
}
|
||||
|
||||
@@ -183,7 +184,8 @@ class view_item
|
||||
|
||||
private:
|
||||
iterator m_it;
|
||||
std::string m_index{}; // NOLINT(readability-redundant-member-init)
|
||||
std::size_t m_position; ///< the index of an array element
|
||||
mutable std::string m_index{}; ///< the text of m_position, once key() was called // NOLINT(readability-redundant-member-init)
|
||||
};
|
||||
|
||||
/// the range returned by basic_json_view::items()
|
||||
|
||||
Reference in new issue
Block a user