mirror of https://github.com/Icinga/icinga2.git
parent
c5b5eccf49
commit
4d125edc0d
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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 */
|
Loading…
Reference in New Issue