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

Method FilterArrayToInt

lib/icinga/customvarobject.cpp:21–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21int icinga::FilterArrayToInt(const Array::Ptr& typeFilters, const std::map<String, int>& filterMap, int defaultValue)
22{
23 int resultTypeFilter;
24
25 if (!typeFilters)
26 return defaultValue;
27
28 resultTypeFilter = 0;
29
30 ObjectLock olock(typeFilters);
31 for (const Value& typeFilter : typeFilters) {
32 if (typeFilter.IsNumber()) {
33 resultTypeFilter = resultTypeFilter | typeFilter;
34 continue;
35 }
36
37 if (!typeFilter.IsString())
38 return -1;
39
40 auto it = filterMap.find(typeFilter);
41
42 if (it == filterMap.end())
43 return -1;
44
45 resultTypeFilter = resultTypeFilter | it->second;
46 }
47
48 return resultTypeFilter;
49}

Callers

nothing calls this directly

Calls 4

IsNumberMethod · 0.80
IsStringMethod · 0.80
findMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected