Add IsInit() function

This commit is contained in:
Mikhail Lobotskiy
2023-12-19 15:10:27 +04:00
parent 5d4f785cc1
commit e4477c9926
3 changed files with 31 additions and 0 deletions

View File

@ -42,6 +42,12 @@ namespace NSJSON
return m_internal->m_type == CTypedValue::vtNull;
}
bool IValue::IsInit() const
{
// the same as (m_internal->m_type != CTypedValue::vtUndefined && m_internal->m_type != CTypedValue::vtNull) but a little bit faster
return m_internal->m_value.get() != nullptr;
}
bool IValue::IsBool() const
{
return (m_internal->m_type == CTypedValue::vtPrimitive &&

View File

@ -50,6 +50,10 @@ namespace NSJSON
* Returns true if the value is null.
*/
bool IsNull() const;
/**
* Returns true if the value is not undefined or null.
*/
bool IsInit() const;
/**
* Returns true if the value is a boolean value.
*/