mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 07:54:58 +00: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
3 changed files with 1 additions and 51 deletions
|
@ -137,7 +137,7 @@ Variant JsonArrayModel::data(ModelIndex const& index, ModelRole role) const
|
||||||
if (!data.has_value())
|
if (!data.has_value())
|
||||||
return "";
|
return "";
|
||||||
if (data->is_number())
|
if (data->is_number())
|
||||||
return data.value();
|
return data->serialized<StringBuilder>();
|
||||||
return data->as_string();
|
return data->as_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,54 +13,6 @@
|
||||||
|
|
||||||
namespace GUI {
|
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
|
bool Variant::operator==(Variant const& other) const
|
||||||
{
|
{
|
||||||
return visit([&]<typename T>(T const& own_value) {
|
return visit([&]<typename T>(T const& own_value) {
|
||||||
|
|
|
@ -29,8 +29,6 @@ public:
|
||||||
using Detail::VariantUnderlyingType::Variant;
|
using Detail::VariantUnderlyingType::Variant;
|
||||||
using Detail::VariantUnderlyingType::operator=;
|
using Detail::VariantUnderlyingType::operator=;
|
||||||
|
|
||||||
Variant(JsonValue const&);
|
|
||||||
Variant& operator=(JsonValue const&);
|
|
||||||
Variant(bool v)
|
Variant(bool v)
|
||||||
: Variant(Detail::Boolean { v })
|
: Variant(Detail::Boolean { v })
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue