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

Method GetComparedName

lib/config/applyrule-targeted.cpp:193–213  ·  view source on GitHub ↗

* If the given filter is like the following, extract the object name ("N"): * * $lcType$.name == "N" * * The order of operands of == doesn't matter. * * @returns The object name on success and nullptr on failure. */

Source from the content-addressed store, hash-verified

191 * @returns The object name on success and nullptr on failure.
192 */
193const String * ApplyRule::GetComparedName(Expression* assignFilter, const char * lcType, const Dictionary::Ptr& constants)
194{
195 auto eq (dynamic_cast<EqualExpression*>(assignFilter));
196
197 if (!eq) {
198 return nullptr;
199 }
200
201 auto op1 (eq->GetOperand1().get());
202 auto op2 (eq->GetOperand2().get());
203
204 if (IsNameIndexer(op1, lcType, constants)) {
205 return GetConstString(op2, constants);
206 }
207
208 if (IsNameIndexer(op2, lcType, constants)) {
209 return GetConstString(op1, constants);
210 }
211
212 return nullptr;
213}
214
215/**
216 * @returns Whether the given expression is like $lcType$.name.

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected