MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / matchQuerySymbolNumber

Method matchQuerySymbolNumber

src/core/objects/symbol_rule_set.cpp:227–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225
226
227void SymbolRuleSet::matchQuerySymbolNumber(const Map& other_map)
228{
229 auto findMatchingSymbol = [&other_map](const Symbol* original, auto compare)->const Symbol*
230 {
231 for (int k = 0; k < other_map.getNumSymbols(); ++k)
232 {
233 auto other_symbol = other_map.getSymbol(k);
234 if ((original->*compare)(other_symbol)
235 && Symbol::areTypesCompatible(original->getType(), other_symbol->getType()))
236 {
237 return other_symbol;
238 }
239 }
240 return nullptr;
241 };
242
243 for (auto& item : *this)
244 {
245 if (item.query.getOperator() != ObjectQuery::OperatorSymbol)
246 continue;
247
248 auto original = item.query.symbolOperand();
249 if (!original)
250 continue;
251
252 auto candidate = findMatchingSymbol(original, &Symbol::numberEquals);
253 if (!candidate)
254 {
255 candidate = findMatchingSymbol(original, &Symbol::numberEqualsRelaxed);
256 }
257 if (candidate != item.symbol)
258 {
259 if (candidate)
260 {
261 item.symbol = candidate;
262 item.type = SymbolRule::AutomaticAssignment;
263 }
264 else
265 {
266 item.type = SymbolRule::NoAssignment;
267 }
268 }
269 }
270}
271
272
273

Callers 2

matchByNumberMethod · 0.80

Calls 5

getNumSymbolsMethod · 0.80
getOperatorMethod · 0.80
symbolOperandMethod · 0.80
getSymbolMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected