MCPcopy Create free account
hub / github.com/Icinga/icinga2 / StringFind

Function StringFind

lib/base/string-script.cpp:67–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67static int StringFind(const std::vector<Value>& args)
68{
69 ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
70 String self = vframe->Self;
71
72 if (args.empty())
73 BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments"));
74
75 String::SizeType result;
76
77 if (args.size() > 1) {
78 if (static_cast<double>(args[1]) < 0)
79 BOOST_THROW_EXCEPTION(std::invalid_argument("String index is out of range"));
80
81 result = self.Find(args[0], args[1]);
82 } else
83 result = self.Find(args[0]);
84
85 if (result == String::NPos)
86 return -1;
87 else
88 return result;
89}
90
91static bool StringContains(const String& str)
92{

Callers

nothing calls this directly

Calls 3

FindMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected