]> granicus.if.org Git - icinga2/commitdiff
Implement shift operator for the Value class.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 23 Jul 2013 06:57:22 +0000 (08:57 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 23 Jul 2013 07:11:53 +0000 (09:11 +0200)
components/livestatus/query.cpp
lib/base/value.cpp
lib/base/value.h
lib/icinga/pluginnotificationtask.cpp

index 6f8defbd7602c7ea042b6ef99dcfaf34df239e86..3d59bcda08bb71f76be396724fb8479b2609c8a6 100644 (file)
@@ -300,7 +300,7 @@ void Query::PrintResultSet(std::ostream& fp, const std::vector<String>& columns,
                                if (value.IsObjectType<Array>())
                                        PrintCsvArray(fp, value, 0);
                                else
-                                       fp << Convert::ToString(value);
+                                       fp << value;
                        }
 
                        fp << "\n";
@@ -324,7 +324,7 @@ void Query::PrintCsvArray(std::ostream& fp, const Array::Ptr& array, int level)
                if (value.IsObjectType<Array>())
                        PrintCsvArray(fp, value, level + 1);
                else
-                       fp << Convert::ToString(value);
+                       fp << value;
        }
 }
 
index 2617fa4a6a666e48c97218ce95704e57e5106914..91a780820d60b9cad563ca3a7b255633567adac4 100644 (file)
@@ -237,3 +237,17 @@ ValueType Value::GetType(void) const
 {
        return static_cast<ValueType>(m_Value.which());
 }
+
+std::ostream& icinga::operator<<(std::ostream& stream, const Value& value)
+{
+       stream << static_cast<String>(value);
+       return stream;
+}
+
+std::istream& icinga::operator>>(std::istream& stream, Value& value)
+{
+       String tstr;
+       stream >> tstr;
+       value = tstr;
+       return stream;
+}
index e5335eeee900d9976b99ddb438705cb00d5ef8f8..a354c29c0e92d1615ded4a08a5e8a0deeae60387 100644 (file)
@@ -114,6 +114,9 @@ private:
 
 static Value Empty;
 
+I2_BASE_API std::ostream& operator<<(std::ostream& stream, const Value& value);
+I2_BASE_API std::istream& operator>>(std::istream& stream, Value& value);
+
 }
 
 #endif /* VALUE_H */
index 1f9a58d6fdc69aaa2cb5504cf2bfae9e1e040ac3..977eb71c3e1688137a3733a134cde04f312ee802 100644 (file)
@@ -26,7 +26,6 @@
 #include "base/scriptfunction.h"
 #include "base/logger_fwd.h"
 #include "base/utility.h"
-#include "base/convert.h"
 #include "base/process.h"
 #include <boost/smart_ptr/make_shared.hpp>
 #include <boost/foreach.hpp>
@@ -87,7 +86,7 @@ void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification, c
 
        if (pr.ExitStatus != 0) {
                std::ostringstream msgbuf;
-               msgbuf << "Notification command '" << Convert::ToString(command) << "' for service '"
+               msgbuf << "Notification command '" << command << "' for service '"
                       << service->GetName() << "' failed; exit status: "
                       << pr.ExitStatus << ", output: " << pr.Output;
                Log(LogWarning, "icinga", msgbuf.str());