mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:27:43 +00:00
AK: Add some convenient functions to JsonValue.
This commit is contained in:
parent
9149a519f5
commit
c5d623e048
1 changed files with 20 additions and 0 deletions
|
@ -49,6 +49,26 @@ public:
|
||||||
return { };
|
return { };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Type type() const { return m_type; }
|
||||||
|
|
||||||
|
bool is_null() const { return m_type == Type::Null; }
|
||||||
|
bool is_undefined() const { return m_type == Type::Undefined; }
|
||||||
|
bool is_string() const { return m_type == Type::String; }
|
||||||
|
bool is_int() const { return m_type == Type::Int; }
|
||||||
|
bool is_double() const { return m_type == Type::Double; }
|
||||||
|
bool is_array() const { return m_type == Type::Array; }
|
||||||
|
bool is_object() const { return m_type == Type::Object; }
|
||||||
|
bool is_number() const { return m_type == Type::Int || m_type == Type::Double; }
|
||||||
|
|
||||||
|
dword to_dword(dword default_value = 0) const
|
||||||
|
{
|
||||||
|
if (!is_number())
|
||||||
|
return default_value;
|
||||||
|
if (type() == Type::Int)
|
||||||
|
return (dword)m_value.as_int;
|
||||||
|
return (dword)m_value.as_double;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clear();
|
void clear();
|
||||||
void copy_from(const JsonValue&);
|
void copy_from(const JsonValue&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue