AK: Add implied const qualifiers to the Json interface

As specified by clang-tidy.
This commit is contained in:
Hendiadyoin1 2021-12-15 14:49:35 +01:00 committed by Brian Gianforcaro
parent b39c4c62d0
commit b429f9c7aa
3 changed files with 16 additions and 16 deletions

View file

@ -69,7 +69,7 @@ public:
template<typename Callback>
void for_each(Callback callback) const
{
for (auto& value : m_values)
for (auto const& value : m_values)
callback(value);
}

View file

@ -49,7 +49,7 @@ public:
[[nodiscard]] JsonValue const& get(StringView key) const
{
auto* value = get_ptr(key);
auto const* value = get_ptr(key);
static JsonValue* s_null_value { nullptr };
if (!value) {
if (!s_null_value)
@ -74,58 +74,58 @@ public:
[[nodiscard]] bool has_null(StringView key) const
{
auto* value = get_ptr(key);
auto const* value = get_ptr(key);
return value && value->is_null();
}
[[nodiscard]] bool has_bool(StringView key) const
{
auto* value = get_ptr(key);
auto const* value = get_ptr(key);
return value && value->is_bool();
}
[[nodiscard]] bool has_string(StringView key) const
{
auto* value = get_ptr(key);
auto const* value = get_ptr(key);
return value && value->is_string();
}
[[nodiscard]] bool has_i32(StringView key) const
{
auto* value = get_ptr(key);
auto const* value = get_ptr(key);
return value && value->is_i32();
}
[[nodiscard]] bool has_u32(StringView key) const
{
auto* value = get_ptr(key);
auto const* value = get_ptr(key);
return value && value->is_u32();
}
[[nodiscard]] bool has_i64(StringView key) const
{
auto* value = get_ptr(key);
auto const* value = get_ptr(key);
return value && value->is_i64();
}
[[nodiscard]] bool has_u64(StringView key) const
{
auto* value = get_ptr(key);
auto const* value = get_ptr(key);
return value && value->is_u64();
}
[[nodiscard]] bool has_number(StringView key) const
{
auto* value = get_ptr(key);
auto const* value = get_ptr(key);
return value && value->is_number();
}
[[nodiscard]] bool has_array(StringView key) const
{
auto* value = get_ptr(key);
auto const* value = get_ptr(key);
return value && value->is_array();
}
[[nodiscard]] bool has_object(StringView key) const
{
auto* value = get_ptr(key);
auto const* value = get_ptr(key);
return value && value->is_object();
}
#ifndef KERNEL
[[nodiscard]] [[nodiscard]] bool has_double(StringView key) const
{
auto* value = get_ptr(key);
auto const* value = get_ptr(key);
return value && value->is_double();
}
#endif
@ -138,7 +138,7 @@ public:
template<typename Callback>
void for_each_member(Callback callback) const
{
for (auto& member : m_members)
for (auto const& member : m_members)
callback(member.key, member.value);
}

View file

@ -16,7 +16,7 @@ JsonPathElement JsonPathElement::any_object_element { Kind::AnyKey };
JsonValue JsonPath::resolve(const JsonValue& top_root) const
{
auto root = top_root;
for (auto& element : *this) {
for (auto const& element : *this) {
switch (element.kind()) {
case JsonPathElement::Kind::Key:
root = JsonValue { root.as_object().get(element.key()) };
@ -35,7 +35,7 @@ String JsonPath::to_string() const
{
StringBuilder builder;
builder.append("{ .");
for (auto& el : *this) {
for (auto const& el : *this) {
builder.append(" > ");
builder.append(el.to_string());
}