MCPcopy Create free account
hub / github.com/comaps/comaps / GetOSMKeyValues

Method GetOSMKeyValues

libs/indexer/feature_charge_sockets.cpp:340–399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338}
339
340OSMKeyValues ChargeSocketsHelper::GetOSMKeyValues()
341{
342 if (m_dirty)
343 Sort();
344
345 std::vector<std::pair<std::string, std::string>> result;
346 std::string lastType;
347 std::ostringstream countStream;
348 std::ostringstream powerStream;
349 bool firstCount = true;
350 bool firstPower = true;
351
352 for (auto const & s : m_chargeSockets)
353 {
354 if (s.type.empty())
355 continue;
356
357 // If we switch type, flush previous streams
358 if (s.type != lastType && !lastType.empty())
359 {
360 result.emplace_back("socket:" + lastType, countStream.str());
361 if (powerStream.str().size() > 0)
362 result.emplace_back("socket:" + lastType + ":output", powerStream.str());
363
364 countStream.str("");
365 countStream.clear();
366 powerStream.str("");
367 powerStream.clear();
368 firstCount = true;
369 firstPower = true;
370 }
371
372 lastType = s.type;
373
374 // Append count
375 if (!firstCount)
376 countStream << ";";
377 countStream << ((s.count > 0) ? std::to_string(s.count) : "yes");
378 firstCount = false;
379
380 // Append power if > 0
381 if (s.power > 0)
382 {
383 if (!firstPower)
384 powerStream << ";";
385 powerStream << to_string_trimmed(s.power);
386 firstPower = false;
387 }
388 }
389
390 // Flush last type
391 if (!lastType.empty())
392 {
393 result.emplace_back("socket:" + lastType, countStream.str());
394 if (powerStream.str().size() > 0)
395 result.emplace_back("socket:" + lastType + ":output", powerStream.str());
396 }
397

Callers 2

DiffMethod · 0.80
UNIT_TESTFunction · 0.80

Calls 7

to_stringFunction · 0.85
to_string_trimmedFunction · 0.85
SortFunction · 0.50
emptyMethod · 0.45
emplace_backMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.64