[icinga-checkins] icinga.org: icinga2/master: livestatus: add = operator for lists comparison

git at icinga.org git at icinga.org
Mon Jul 22 14:27:07 CEST 2013


Module: icinga2
Branch: master
Commit: 81b3b489989dfe38b392cc21c043a110464725b9
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=81b3b489989dfe38b392cc21c043a110464725b9

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Mon Jul 22 14:26:18 2013 +0200

livestatus: add = operator for lists comparison

refs #2743

---

 components/livestatus/attributefilter.cpp |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/components/livestatus/attributefilter.cpp b/components/livestatus/attributefilter.cpp
index 6b510fa..3f9b0f0 100644
--- a/components/livestatus/attributefilter.cpp
+++ b/components/livestatus/attributefilter.cpp
@@ -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 == "=") {





More information about the icinga-checkins mailing list