From: Gunnar Beutner Date: Tue, 23 Jul 2013 06:57:22 +0000 (+0200) Subject: Implement shift operator for the Value class. X-Git-Tag: v0.0.3~797 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cab2b41e56202332e10b7d783cbd8889b25cbe32;p=icinga2 Implement shift operator for the Value class. --- diff --git a/components/livestatus/query.cpp b/components/livestatus/query.cpp index 6f8defbd7..3d59bcda0 100644 --- a/components/livestatus/query.cpp +++ b/components/livestatus/query.cpp @@ -300,7 +300,7 @@ void Query::PrintResultSet(std::ostream& fp, const std::vector& columns, if (value.IsObjectType()) 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()) PrintCsvArray(fp, value, level + 1); else - fp << Convert::ToString(value); + fp << value; } } diff --git a/lib/base/value.cpp b/lib/base/value.cpp index 2617fa4a6..91a780820 100644 --- a/lib/base/value.cpp +++ b/lib/base/value.cpp @@ -237,3 +237,17 @@ ValueType Value::GetType(void) const { return static_cast(m_Value.which()); } + +std::ostream& icinga::operator<<(std::ostream& stream, const Value& value) +{ + stream << static_cast(value); + return stream; +} + +std::istream& icinga::operator>>(std::istream& stream, Value& value) +{ + String tstr; + stream >> tstr; + value = tstr; + return stream; +} diff --git a/lib/base/value.h b/lib/base/value.h index e5335eeee..a354c29c0 100644 --- a/lib/base/value.h +++ b/lib/base/value.h @@ -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 */ diff --git a/lib/icinga/pluginnotificationtask.cpp b/lib/icinga/pluginnotificationtask.cpp index 1f9a58d6f..977eb71c3 100644 --- a/lib/icinga/pluginnotificationtask.cpp +++ b/lib/icinga/pluginnotificationtask.cpp @@ -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 #include @@ -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());