mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:57:45 +00:00
JsonValue: Add is_bool() and various as_foo() helpers.
This commit is contained in:
parent
7f224ade60
commit
293946c960
1 changed files with 19 additions and 0 deletions
|
@ -57,6 +57,24 @@ public:
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int as_int() const
|
||||||
|
{
|
||||||
|
ASSERT(is_int());
|
||||||
|
return m_value.as_int;
|
||||||
|
}
|
||||||
|
|
||||||
|
int as_uint() const
|
||||||
|
{
|
||||||
|
ASSERT(is_uint());
|
||||||
|
return m_value.as_uint;
|
||||||
|
}
|
||||||
|
|
||||||
|
int as_bool() const
|
||||||
|
{
|
||||||
|
ASSERT(is_bool());
|
||||||
|
return m_value.as_bool;
|
||||||
|
}
|
||||||
|
|
||||||
String as_string() const
|
String as_string() const
|
||||||
{
|
{
|
||||||
ASSERT(is_string());
|
ASSERT(is_string());
|
||||||
|
@ -79,6 +97,7 @@ public:
|
||||||
|
|
||||||
bool is_null() const { return m_type == Type::Null; }
|
bool is_null() const { return m_type == Type::Null; }
|
||||||
bool is_undefined() const { return m_type == Type::Undefined; }
|
bool is_undefined() const { return m_type == Type::Undefined; }
|
||||||
|
bool is_bool() const { return m_type == Type::Bool; }
|
||||||
bool is_string() const { return m_type == Type::String; }
|
bool is_string() const { return m_type == Type::String; }
|
||||||
bool is_int() const { return m_type == Type::Int; }
|
bool is_int() const { return m_type == Type::Int; }
|
||||||
bool is_uint() const { return m_type == Type::UnsignedInt; }
|
bool is_uint() const { return m_type == Type::UnsignedInt; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue