diff --git a/lib/base/Makefile.am b/lib/base/Makefile.am index 575a83546..e853892e8 100644 --- a/lib/base/Makefile.am +++ b/lib/base/Makefile.am @@ -12,6 +12,8 @@ libbase_la_SOURCES = \ component.h \ connection.cpp \ connection.h \ + convert.cpp \ + convert.h \ dictionary.cpp \ dictionary.h \ dynamicobject.cpp \ diff --git a/lib/base/qstring.cpp b/lib/base/qstring.cpp index 30538c509..4ac2d206a 100644 --- a/lib/base/qstring.cpp +++ b/lib/base/qstring.cpp @@ -159,11 +159,6 @@ String::ConstIterator String::End(void) const return m_Data.end(); } -double String::ToDouble(void) const -{ - return strtod(CStr(), NULL); -} - ostream& icinga::operator<<(ostream& stream, const String& str) { stream << static_cast(str); diff --git a/lib/base/qstring.h b/lib/base/qstring.h index d6cbecf4f..154cb6245 100644 --- a/lib/base/qstring.h +++ b/lib/base/qstring.h @@ -87,8 +87,6 @@ public: Iterator End(void); ConstIterator End(void) const; - double ToDouble(void) const; - static const size_t NPos; private: diff --git a/lib/icinga/externalcommand.cpp b/lib/icinga/externalcommand.cpp index e72e6ad85..dcddf090f 100644 --- a/lib/icinga/externalcommand.cpp +++ b/lib/icinga/externalcommand.cpp @@ -40,7 +40,7 @@ void ExternalCommand::Execute(const String& line) String timestamp = line.SubStr(1, pos - 1); String args = line.SubStr(pos + 2, String::NPos); - double ts = timestamp.ToDouble(); + double ts = Convert::ToDouble(timestamp); if (ts == 0) throw_exception(invalid_argument("Invalid timestamp in command: " + line)); @@ -121,7 +121,7 @@ void ExternalCommand::ProcessServiceCheckResult(double time, const vectorGetEnablePassiveChecks()) throw_exception(invalid_argument("Got passive check result for service '" + arguments[1] + "' which has passive checks disabled.")); - int exitStatus = arguments[2].ToDouble(); + int exitStatus = Convert::ToDouble(arguments[2]); Dictionary::Ptr result = PluginCheckTask::ParseCheckOutput(arguments[3]); result->Set("state", PluginCheckTask::ExitStatusToState(exitStatus)); @@ -151,7 +151,7 @@ void ExternalCommand::ScheduleSvcCheck(double time, const vector& argume Service::Ptr service = Service::GetByName(arguments[1]); - double planned_check = arguments[2].ToDouble(); + double planned_check = Convert::ToDouble(arguments[2]); if (planned_check > service->GetNextCheck()) { Logger::Write(LogInformation, "icinga", "Ignoring reschedule request for service '" + @@ -175,7 +175,7 @@ void ExternalCommand::ScheduleForcedSvcCheck(double time, const vector& Logger::Write(LogInformation, "icinga", "Rescheduling next check for service '" + arguments[1] + "'"); service->SetForceNextCheck(true); - service->SetNextCheck(arguments[2].ToDouble()); + service->SetNextCheck(Convert::ToDouble(arguments[2])); } void ExternalCommand::EnableSvcCheck(double time, const vector& arguments) @@ -220,7 +220,7 @@ void ExternalCommand::ScheduleForcedHostSvcChecks(double time, const vector& a if (!Host::Exists(arguments[0])) throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist.")); - double planned_check = arguments[1].ToDouble(); + double planned_check = Convert::ToDouble(arguments[1]); Host::Ptr host = Host::GetByName(arguments[0]); @@ -319,7 +319,7 @@ void ExternalCommand::AcknowledgeSvcProblem(double time, const vector& a if (!Service::Exists(arguments[1])) throw_exception(invalid_argument("The service '" + arguments[1] + "' does not exist.")); - int sticky = arguments[2].ToDouble(); + bool sticky = Convert::ToBool(arguments[2]); Service::Ptr service = Service::GetByName(arguments[1]); @@ -339,8 +339,8 @@ void ExternalCommand::AcknowledgeSvcProblemExpire(double time, const vector& if (!Host::Exists(arguments[0])) throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist.")); - int sticky = arguments[0].ToDouble(); + bool sticky = Convert::ToBool(arguments[0]); Host::Ptr host = Host::GetByName(arguments[0]); @@ -395,8 +395,8 @@ void ExternalCommand::AcknowledgeHostProblemExpire(double time, const vector& arguments) throw_exception(invalid_argument("Expected 2 arguments.")); String file = arguments[0]; - int del = arguments[1].ToDouble(); + bool del = Convert::ToBool(arguments[1]); ifstream ifp; ifp.exceptions(ifstream::badbit);