mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-08 23:42:53 +03:00
LibGUI: Remove GUI::Variant::Variant(JsonValue const&)
Let's force callers of Variant constructor to know the type of the object they are constructing.
This commit is contained in:
parent
77f36a9e46
commit
0388c828be
Notes:
sideshowbarker
2024-07-16 23:23:26 +09:00
Author: https://github.com/DanShaders Commit: https://github.com/SerenityOS/serenity/commit/0388c828be Pull-request: https://github.com/SerenityOS/serenity/pull/22729 Reviewed-by: https://github.com/ADKaster ✅
@ -137,7 +137,7 @@ Variant JsonArrayModel::data(ModelIndex const& index, ModelRole role) const
|
||||
if (!data.has_value())
|
||||
return "";
|
||||
if (data->is_number())
|
||||
return data.value();
|
||||
return data->serialized<StringBuilder>();
|
||||
return data->as_string();
|
||||
}
|
||||
|
||||
|
@ -13,54 +13,6 @@
|
||||
|
||||
namespace GUI {
|
||||
|
||||
Variant::Variant(JsonValue const& value)
|
||||
{
|
||||
*this = value;
|
||||
}
|
||||
|
||||
Variant& Variant::operator=(JsonValue const& value)
|
||||
{
|
||||
if (value.is_null())
|
||||
return *this;
|
||||
|
||||
if (value.is_i32()) {
|
||||
set(value.as_i32());
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (value.is_u32()) {
|
||||
set(value.as_u32());
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (value.is_i64()) {
|
||||
set(value.as_i64());
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (value.is_u64()) {
|
||||
set(value.as_u64());
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (value.is_double()) {
|
||||
set(value.as_double());
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (value.is_string()) {
|
||||
set(value.as_string());
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (value.is_bool()) {
|
||||
set(Detail::Boolean { value.as_bool() });
|
||||
return *this;
|
||||
}
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
bool Variant::operator==(Variant const& other) const
|
||||
{
|
||||
return visit([&]<typename T>(T const& own_value) {
|
||||
|
@ -29,8 +29,6 @@ public:
|
||||
using Detail::VariantUnderlyingType::Variant;
|
||||
using Detail::VariantUnderlyingType::operator=;
|
||||
|
||||
Variant(JsonValue const&);
|
||||
Variant& operator=(JsonValue const&);
|
||||
Variant(bool v)
|
||||
: Variant(Detail::Boolean { v })
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user