]> granicus.if.org Git - icinga2/commitdiff
Move the cast functions into libbase
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 24 Nov 2014 06:09:51 +0000 (07:09 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 24 Nov 2014 06:09:51 +0000 (07:09 +0100)
fixes #7807

lib/base/scriptutils.cpp
lib/base/scriptutils.hpp
lib/methods/CMakeLists.txt
lib/methods/castfuncs.cpp [deleted file]
lib/methods/castfuncs.hpp [deleted file]

index 56d68590827b9d5f63913321f0c8f0b48ee663ad..5f5a08bdd5a07fce0d420ddc1748d5dbe99ca3f9 100644 (file)
@@ -47,7 +47,24 @@ REGISTER_SCRIPTFUNCTION(keys, &ScriptUtils::Keys);
 REGISTER_SCRIPTFUNCTION(random, &Utility::Random);
 REGISTER_SCRIPTFUNCTION(__get_object, &ScriptUtils::GetObject);
 REGISTER_SCRIPTFUNCTION(assert, &ScriptUtils::Assert);
+REGISTER_SCRIPTFUNCTION(string, &ScriptUtils::CastString);
+REGISTER_SCRIPTFUNCTION(number, &ScriptUtils::CastNumber);
+REGISTER_SCRIPTFUNCTION(bool, &ScriptUtils::CastBool);
 
+String ScriptUtils::CastString(const Value& value)
+{
+       return value;
+}
+
+double ScriptUtils::CastNumber(const Value& value)
+{
+       return value;
+}
+
+bool ScriptUtils::CastBool(const Value& value)
+{
+       return value.ToBool();
+}
 bool ScriptUtils::Regex(const String& pattern, const String& text)
 {
        bool res = false;
index a119d426960ce879644867f768fca9502676424c..debcdd607973fc326ec8c07781581f2fcd3fab4e 100644 (file)
@@ -36,6 +36,9 @@ namespace icinga
 class I2_BASE_API ScriptUtils
 {
 public:
+       static String CastString(const Value& value);
+       static double CastNumber(const Value& value);
+       static bool CastBool(const Value& value);
        static bool Regex(const String& pattern, const String& text);
        static int Len(const Value& value);
        static Array::Ptr Union(const std::vector<Value>& arguments);
index 35b5571388ef189841fa942386fd068a6bd50ad9..bb3cf63cd1f117f775972d0263c7ab19b5ab76df 100644 (file)
@@ -22,7 +22,7 @@ else()
 endif()
 
 set(methods_SOURCES
-  castfuncs.cpp clusterchecktask.cpp clusterzonechecktask.cpp
+  clusterchecktask.cpp clusterzonechecktask.cpp
   icingachecktask.cpp nullchecktask.cpp nulleventtask.cpp
   pluginchecktask.cpp plugineventtask.cpp pluginnotificationtask.cpp
   randomchecktask.cpp timeperiodtask.cpp ${WindowsSources}
diff --git a/lib/methods/castfuncs.cpp b/lib/methods/castfuncs.cpp
deleted file mode 100644 (file)
index a925edd..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************
- * Icinga 2                                                                   *
- * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org)    *
- *                                                                            *
- * This program is free software; you can redistribute it and/or              *
- * modify it under the terms of the GNU General Public License                *
- * as published by the Free Software Foundation; either version 2             *
- * of the License, or (at your option) any later version.                     *
- *                                                                            *
- * This program is distributed in the hope that it will be useful,            *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
- * GNU General Public License for more details.                               *
- *                                                                            *
- * You should have received a copy of the GNU General Public License          *
- * along with this program; if not, write to the Free Software Foundation     *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
- ******************************************************************************/
-
-#include "methods/castfuncs.hpp"
-#include "base/scriptfunction.hpp"
-
-using namespace icinga;
-
-REGISTER_SCRIPTFUNCTION(string, &CastFuncs::CastString);
-REGISTER_SCRIPTFUNCTION(number, &CastFuncs::CastNumber);
-REGISTER_SCRIPTFUNCTION(bool, &CastFuncs::CastBool);
-
-String CastFuncs::CastString(const Value& value)
-{
-       return value;
-}
-
-double CastFuncs::CastNumber(const Value& value)
-{
-       return value;
-}
-
-bool CastFuncs::CastBool(const Value& value)
-{
-       return value.ToBool();
-}
diff --git a/lib/methods/castfuncs.hpp b/lib/methods/castfuncs.hpp
deleted file mode 100644 (file)
index b8612af..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/******************************************************************************
- * Icinga 2                                                                   *
- * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org)    *
- *                                                                            *
- * This program is free software; you can redistribute it and/or              *
- * modify it under the terms of the GNU General Public License                *
- * as published by the Free Software Foundation; either version 2             *
- * of the License, or (at your option) any later version.                     *
- *                                                                            *
- * This program is distributed in the hope that it will be useful,            *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
- * GNU General Public License for more details.                               *
- *                                                                            *
- * You should have received a copy of the GNU General Public License          *
- * along with this program; if not, write to the Free Software Foundation     *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
- ******************************************************************************/
-
-#ifndef CASTFUNCS_H
-#define CASTFUNCS_H
-
-#include "methods/i2-methods.hpp"
-#include "base/string.hpp"
-
-namespace icinga
-{
-
-/**
- * @ingroup methods
- */
-class I2_METHODS_API CastFuncs
-{
-public:
-       static String CastString(const Value& value);
-       static double CastNumber(const Value& value);
-       static bool CastBool(const Value& value);
-
-private:
-       CastFuncs(void);
-};
-
-}
-
-#endif /* CASTFUNCS_H */