Handle empty Json values:

* Replace Json::Value::isNull() and Json::Value::empty with operator bool()
This commit is contained in:
Tom Ritchford
2015-06-18 15:37:29 -04:00
committed by Nik Bougalis
parent a5a9242f4e
commit 9111ad1a9d
22 changed files with 67 additions and 77 deletions

View File

@@ -822,28 +822,20 @@ Value::size () const
}
bool
Value::empty () const
Value::operator bool () const
{
if (isNull ())
return true;
return false;
if (isString ()) {
if (isString ())
{
auto s = asCString();
return !(s && strlen(s));
return s && strlen(s);
}
return (isArray () || isObject ()) && ! size ();
return ! (isArray () || isObject ()) || size ();
}
bool
Value::operator! () const
{
return isNull ();
}
void
Value::clear ()
{