mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-07 20:25:08 +02:00
Use simplified if conditions where applicable
This commit is contained in:
parent
38313434d2
commit
7b91b200f5
@ -211,18 +211,18 @@ Value icinga::operator+(const Value& lhs, const Value& rhs)
|
||||
return static_cast<double>(lhs) + static_cast<double>(rhs);
|
||||
if ((lhs.IsString() || lhs.IsEmpty() || lhs.IsNumber()) && (rhs.IsString() || rhs.IsEmpty() || rhs.IsNumber()) && (!(lhs.IsEmpty() && rhs.IsEmpty()) || lhs.IsString() || rhs.IsString()))
|
||||
return static_cast<String>(lhs) + static_cast<String>(rhs);
|
||||
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
return static_cast<double>(lhs) + static_cast<double>(rhs);
|
||||
else if (lhs.IsObjectType<DateTime>() && rhs.IsNumber())
|
||||
return new DateTime(Convert::ToDateTimeValue(lhs) + rhs);
|
||||
else if ((lhs.IsObjectType<Array>() || lhs.IsEmpty()) && (rhs.IsObjectType<Array>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty())) {
|
||||
else if ((lhs.IsObjectType<Array>() || lhs.IsEmpty()) && (rhs.IsObjectType<Array>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty())) {
|
||||
Array::Ptr result = new Array();
|
||||
if (!lhs.IsEmpty())
|
||||
static_cast<Array::Ptr>(lhs)->CopyTo(result);
|
||||
if (!rhs.IsEmpty())
|
||||
static_cast<Array::Ptr>(rhs)->CopyTo(result);
|
||||
return result;
|
||||
} else if ((lhs.IsObjectType<Dictionary>() || lhs.IsEmpty()) && (rhs.IsObjectType<Dictionary>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty())) {
|
||||
} else if ((lhs.IsObjectType<Dictionary>() || lhs.IsEmpty()) && (rhs.IsObjectType<Dictionary>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty())) {
|
||||
Dictionary::Ptr result = new Dictionary();
|
||||
if (!lhs.IsEmpty())
|
||||
static_cast<Dictionary::Ptr>(lhs)->CopyTo(result);
|
||||
@ -262,7 +262,7 @@ Value icinga::operator-(const Value& lhs, const Value& rhs)
|
||||
return new DateTime(Convert::ToDateTimeValue(lhs) - rhs);
|
||||
else if (lhs.IsObjectType<DateTime>() && rhs.IsObjectType<DateTime>())
|
||||
return Convert::ToDateTimeValue(lhs) - Convert::ToDateTimeValue(rhs);
|
||||
else if ((lhs.IsObjectType<DateTime>() || lhs.IsEmpty()) && (rhs.IsObjectType<DateTime>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
else if ((lhs.IsObjectType<DateTime>() || lhs.IsEmpty()) && (rhs.IsObjectType<DateTime>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
return new DateTime(Convert::ToDateTimeValue(lhs) - Convert::ToDateTimeValue(rhs));
|
||||
else if ((lhs.IsObjectType<Array>() || lhs.IsEmpty()) && (rhs.IsObjectType<Array>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty())) {
|
||||
if (lhs.IsEmpty())
|
||||
@ -554,7 +554,7 @@ bool icinga::operator<(const Value& lhs, const Value& rhs)
|
||||
return static_cast<String>(lhs) < static_cast<String>(rhs);
|
||||
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
return static_cast<double>(lhs) < static_cast<double>(rhs);
|
||||
else if ((lhs.IsObjectType<DateTime>() || lhs.IsEmpty()) && (rhs.IsObjectType<DateTime>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
else if ((lhs.IsObjectType<DateTime>() || lhs.IsEmpty()) && (rhs.IsObjectType<DateTime>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
return Convert::ToDateTimeValue(lhs) < Convert::ToDateTimeValue(rhs);
|
||||
else if (lhs.IsObjectType<Array>() && rhs.IsObjectType<Array>()) {
|
||||
Array::Ptr larr = lhs;
|
||||
@ -607,7 +607,7 @@ bool icinga::operator>(const Value& lhs, const Value& rhs)
|
||||
return static_cast<String>(lhs) > static_cast<String>(rhs);
|
||||
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
return static_cast<double>(lhs) > static_cast<double>(rhs);
|
||||
else if ((lhs.IsObjectType<DateTime>() || lhs.IsEmpty()) && (rhs.IsObjectType<DateTime>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
else if ((lhs.IsObjectType<DateTime>() || lhs.IsEmpty()) && (rhs.IsObjectType<DateTime>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
return Convert::ToDateTimeValue(lhs) > Convert::ToDateTimeValue(rhs);
|
||||
else if (lhs.IsObjectType<Array>() && rhs.IsObjectType<Array>()) {
|
||||
Array::Ptr larr = lhs;
|
||||
@ -660,7 +660,7 @@ bool icinga::operator<=(const Value& lhs, const Value& rhs)
|
||||
return static_cast<String>(lhs) <= static_cast<String>(rhs);
|
||||
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
return static_cast<double>(lhs) <= static_cast<double>(rhs);
|
||||
else if ((lhs.IsObjectType<DateTime>() || lhs.IsEmpty()) && (rhs.IsObjectType<DateTime>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
else if ((lhs.IsObjectType<DateTime>() || lhs.IsEmpty()) && (rhs.IsObjectType<DateTime>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
return Convert::ToDateTimeValue(lhs) <= Convert::ToDateTimeValue(rhs);
|
||||
else
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Operator <= cannot be applied to values of type '" + lhs.GetTypeName() + "' and '" + rhs.GetTypeName() + "'"));
|
||||
@ -692,7 +692,7 @@ bool icinga::operator>=(const Value& lhs, const Value& rhs)
|
||||
return static_cast<String>(lhs) >= static_cast<String>(rhs);
|
||||
else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
return static_cast<double>(lhs) >= static_cast<double>(rhs);
|
||||
else if ((lhs.IsObjectType<DateTime>() || lhs.IsEmpty()) && (rhs.IsObjectType<DateTime>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
else if ((lhs.IsObjectType<DateTime>() || lhs.IsEmpty()) && (rhs.IsObjectType<DateTime>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
|
||||
return Convert::ToDateTimeValue(lhs) >= Convert::ToDateTimeValue(rhs);
|
||||
else
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Operator >= cannot be applied to values of type '" + lhs.GetTypeName() + "' and '" + rhs.GetTypeName() + "'"));
|
||||
|
@ -148,7 +148,7 @@ public:
|
||||
{
|
||||
ConfigItem::Ptr item = ConfigItem::GetByTypeAndName(Type::GetByName(type), name);
|
||||
|
||||
if (!item || (item && item->IsAbstract()))
|
||||
if (!item || item->IsAbstract())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user