Space::to_bool() return true now when a string/object or table is non empty

This commit is contained in:
Tomasz Sowa 2021-10-20 08:30:57 +02:00
parent c54c398828
commit 5eff9a5f4f
1 changed files with 25 additions and 2 deletions

View File

@ -827,8 +827,31 @@ bool Space::to_bool() const
if( type == type_bool )
return value.value_bool;
long long val = to_long_long();
return (val != 0) ? true : false;
if( type == type_long )
return value.value_long != 0;
if( type == type_float )
return value.value_float != 0.0f;
if( type == type_double )
return value.value_double != 0.0;
if( type == type_long_double )
return value.value_long_double != 0.0L;
if( type == type_string )
return !value.value_string.empty();
if( type == type_wstring )
return !value.value_wstring.empty();
if( type == type_table )
return !value.value_table.empty();
if( type == type_object )
return !value.value_object.empty();
return false;
}
short Space::to_short() const