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:
Dan Klishch 2023-11-14 00:17:08 -05:00 committed by Andrew Kaster
parent 77f36a9e46
commit 0388c828be
Notes: sideshowbarker 2024-07-16 23:23:26 +09:00
3 changed files with 1 additions and 51 deletions

View File

@ -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();
}

View File

@ -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) {

View File

@ -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 })
{