[icinga-checkins] icinga.org: icinga2/next: Implement String::GetData.

git at icinga.org git at icinga.org
Tue Nov 5 19:01:24 CET 2013


Module: icinga2
Branch: next
Commit: 27f527d0adcba010c874a77064d2ecf29df65cbd
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=27f527d0adcba010c874a77064d2ecf29df65cbd

Author: Gunnar Beutner <gunnar at beutner.name>
Date:   Tue Nov  5 18:52:13 2013 +0100

Implement String::GetData.

Fixes #5008

---

 components/livestatus/attributefilter.cpp |   18 ++++++------------
 lib/base/qstring.cpp                      |    5 +++++
 lib/base/qstring.h                        |    2 ++
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/components/livestatus/attributefilter.cpp b/components/livestatus/attributefilter.cpp
index 76dcf50..bb32540 100644
--- a/components/livestatus/attributefilter.cpp
+++ b/components/livestatus/attributefilter.cpp
@@ -61,13 +61,10 @@ bool AttributeFilter::Apply(const Table::Ptr& table, const Value& row)
 			else
 				return (static_cast<String>(value) == m_Operand);
 		} else if (m_Operator == "~") {
-			boost::regex expr(static_cast<std::string>(m_Operand));
+			boost::regex expr(m_Operand.GetData());
+			String operand = value;
 			boost::smatch what;
-			String val = static_cast<String>(value);
-			std::string::const_iterator begin = val.Begin();
-			std::string::const_iterator end = val.End();
-
-			bool ret = boost::regex_search(begin, end, what, expr);
+			bool ret = boost::regex_search(operand.GetData(), what, expr);
 
 			//Log(LogDebug, "livestatus", "Attribute filter '" + m_Operand + " " + m_Operator + " " +
 			//    static_cast<String>(value) + "' " + (ret ? "matches" : "doesn't match") + "." );
@@ -76,13 +73,10 @@ bool AttributeFilter::Apply(const Table::Ptr& table, const Value& row)
 		} else if (m_Operator == "=~") {
 			return string_iless()(value, m_Operand);
 		} else if (m_Operator == "~~") {
-			boost::regex expr(static_cast<std::string>(m_Operand), boost::regex::icase);
+			boost::regex expr(m_Operand.GetData(), boost::regex::icase);
+			String operand = value;
 			boost::smatch what;
-			String val = static_cast<String>(value);
-			std::string::const_iterator begin = val.Begin();
-			std::string::const_iterator end = val.End();
-
-			bool ret = boost::regex_search(begin, end, what, expr);
+			bool ret = boost::regex_search(operand.GetData(), what, expr);
 
 			//Log(LogDebug, "livestatus", "Attribute filter '" + m_Operand + " " + m_Operator + " " +
 			//    static_cast<String>(value) + "' " + (ret ? "matches" : "doesn't match") + "." );
diff --git a/lib/base/qstring.cpp b/lib/base/qstring.cpp
index beb41b6..80e0826 100644
--- a/lib/base/qstring.cpp
+++ b/lib/base/qstring.cpp
@@ -122,6 +122,11 @@ size_t String::GetLength(void) const
 	return m_Data.size();
 }
 
+std::string& String::GetData(void)
+{
+	return m_Data;
+}
+
 size_t String::Find(const String& str, size_t pos) const
 {
 	return m_Data.find(str, pos);
diff --git a/lib/base/qstring.h b/lib/base/qstring.h
index 52aa312..e26717f 100644
--- a/lib/base/qstring.h
+++ b/lib/base/qstring.h
@@ -76,6 +76,8 @@ public:
 	void Clear(void);
 	size_t GetLength(void) const;
 
+	std::string& GetData(void);
+
 	size_t Find(const String& str, size_t pos = 0) const;
 	size_t FindFirstOf(const char *s, size_t pos = 0) const;
 	size_t FindFirstOf(char ch, size_t pos = 0) const;





More information about the icinga-checkins mailing list