mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
JsonValue: Add is_bool() and various as_foo() helpers.
This commit is contained in:
parent
7f224ade60
commit
293946c960
Notes:
sideshowbarker
2024-07-19 13:27:09 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/293946c9601
1 changed files with 19 additions and 0 deletions
|
@ -57,6 +57,24 @@ public:
|
|||
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
|
||||
{
|
||||
ASSERT(is_string());
|
||||
|
@ -79,6 +97,7 @@ public:
|
|||
|
||||
bool is_null() const { return m_type == Type::Null; }
|
||||
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_int() const { return m_type == Type::Int; }
|
||||
bool is_uint() const { return m_type == Type::UnsignedInt; }
|
||||
|
|
Loading…
Add table
Reference in a new issue