]> granicus.if.org Git - icinga2/commitdiff
livestatus: add = operator for lists comparison
authorMichael Friedrich <michael.friedrich@netways.de>
Mon, 22 Jul 2013 12:26:18 +0000 (14:26 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Mon, 22 Jul 2013 12:26:18 +0000 (14:26 +0200)
refs #2743

components/livestatus/attributefilter.cpp

index 6b510fad027c93e1a6c4d2d77678d1951b96354e..3f9b0f0df327351a66579347719fb0af98515d5a 100644 (file)
@@ -37,8 +37,9 @@ bool AttributeFilter::Apply(const Table::Ptr& table, const Value& row)
        Value value = column.ExtractValue(row);
 
        if (value.IsObjectType<Array>()) {
+               Array::Ptr array = value;
+
                if (m_Operator == ">=") {
-                       Array::Ptr array = value;
                        ObjectLock olock(array);
                        BOOST_FOREACH(const String& item, array) {
                                if (item == m_Operand)
@@ -46,8 +47,10 @@ bool AttributeFilter::Apply(const Table::Ptr& table, const Value& row)
                        }
 
                        return false; /* Item not found in list. */
+               } else if (m_Operator == "=") {
+                       return (array->GetLength() == 0);
                } else {
-                       BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid operator for column '" + m_Column + "': " + m_Operator + " (expected '>=')."));
+                       BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid operator for column '" + m_Column + "': " + m_Operator + " (expected '>=' or '=')."));
                }
        } else {
                if (m_Operator == "=") {