1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 18:47:44 +00:00

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> template<typename Callback>
void for_each(Callback callback) const void for_each(Callback callback) const
{ {
for (auto& value : m_values) for (auto const& value : m_values)
callback(value); callback(value);
} }

View file

@ -49,7 +49,7 @@ public:
[[nodiscard]] JsonValue const& get(StringView key) const [[nodiscard]] JsonValue const& get(StringView key) const
{ {
auto* value = get_ptr(key); auto const* value = get_ptr(key);
static JsonValue* s_null_value { nullptr }; static JsonValue* s_null_value { nullptr };
if (!value) { if (!value) {
if (!s_null_value) if (!s_null_value)
@ -74,58 +74,58 @@ public:
[[nodiscard]] bool has_null(StringView key) const [[nodiscard]] bool has_null(StringView key) const
{ {
auto* value = get_ptr(key); auto const* value = get_ptr(key);
return value && value->is_null(); return value && value->is_null();
} }
[[nodiscard]] bool has_bool(StringView key) const [[nodiscard]] bool has_bool(StringView key) const
{ {
auto* value = get_ptr(key); auto const* value = get_ptr(key);
return value && value->is_bool(); return value && value->is_bool();
} }
[[nodiscard]] bool has_string(StringView key) const [[nodiscard]] bool has_string(StringView key) const
{ {
auto* value = get_ptr(key); auto const* value = get_ptr(key);
return value && value->is_string(); return value && value->is_string();
} }
[[nodiscard]] bool has_i32(StringView key) const [[nodiscard]] bool has_i32(StringView key) const
{ {
auto* value = get_ptr(key); auto const* value = get_ptr(key);
return value && value->is_i32(); return value && value->is_i32();
} }
[[nodiscard]] bool has_u32(StringView key) const [[nodiscard]] bool has_u32(StringView key) const
{ {
auto* value = get_ptr(key); auto const* value = get_ptr(key);
return value && value->is_u32(); return value && value->is_u32();
} }
[[nodiscard]] bool has_i64(StringView key) const [[nodiscard]] bool has_i64(StringView key) const
{ {
auto* value = get_ptr(key); auto const* value = get_ptr(key);
return value && value->is_i64(); return value && value->is_i64();
} }
[[nodiscard]] bool has_u64(StringView key) const [[nodiscard]] bool has_u64(StringView key) const
{ {
auto* value = get_ptr(key); auto const* value = get_ptr(key);
return value && value->is_u64(); return value && value->is_u64();
} }
[[nodiscard]] bool has_number(StringView key) const [[nodiscard]] bool has_number(StringView key) const
{ {
auto* value = get_ptr(key); auto const* value = get_ptr(key);
return value && value->is_number(); return value && value->is_number();
} }
[[nodiscard]] bool has_array(StringView key) const [[nodiscard]] bool has_array(StringView key) const
{ {
auto* value = get_ptr(key); auto const* value = get_ptr(key);
return value && value->is_array(); return value && value->is_array();
} }
[[nodiscard]] bool has_object(StringView key) const [[nodiscard]] bool has_object(StringView key) const
{ {
auto* value = get_ptr(key); auto const* value = get_ptr(key);
return value && value->is_object(); return value && value->is_object();
} }
#ifndef KERNEL #ifndef KERNEL
[[nodiscard]] [[nodiscard]] bool has_double(StringView key) const [[nodiscard]] [[nodiscard]] bool has_double(StringView key) const
{ {
auto* value = get_ptr(key); auto const* value = get_ptr(key);
return value && value->is_double(); return value && value->is_double();
} }
#endif #endif
@ -138,7 +138,7 @@ public:
template<typename Callback> template<typename Callback>
void for_each_member(Callback callback) const void for_each_member(Callback callback) const
{ {
for (auto& member : m_members) for (auto const& member : m_members)
callback(member.key, member.value); 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 JsonValue JsonPath::resolve(const JsonValue& top_root) const
{ {
auto root = top_root; auto root = top_root;
for (auto& element : *this) { for (auto const& element : *this) {
switch (element.kind()) { switch (element.kind()) {
case JsonPathElement::Kind::Key: case JsonPathElement::Kind::Key:
root = JsonValue { root.as_object().get(element.key()) }; root = JsonValue { root.as_object().get(element.key()) };
@ -35,7 +35,7 @@ String JsonPath::to_string() const
{ {
StringBuilder builder; StringBuilder builder;
builder.append("{ ."); builder.append("{ .");
for (auto& el : *this) { for (auto const& el : *this) {
builder.append(" > "); builder.append(" > ");
builder.append(el.to_string()); builder.append(el.to_string());
} }