MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / replaceTokensIn

Function replaceTokensIn

launcher/minecraft/MinecraftInstance.cpp:504–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

502}
503
504static QString replaceTokensIn(QString text, QMap<QString, QString> with)
505{
506 // TODO: does this still work??
507 QString result;
508 QRegularExpression token_regexp("\\$\\{(.+)\\}", QRegularExpression::InvertedGreedinessOption);
509 QStringList list;
510 QRegularExpressionMatchIterator i = token_regexp.globalMatch(text);
511 int lastCapturedEnd = 0;
512 while (i.hasNext())
513 {
514 QRegularExpressionMatch match = i.next();
515 result.append(text.mid(lastCapturedEnd, match.capturedStart()));
516 QString key = match.captured(1);
517 auto iter = with.find(key);
518 if (iter != with.end())
519 {
520 result.append(*iter);
521 }
522 lastCapturedEnd = match.capturedEnd();
523 }
524 result.append(text.mid(lastCapturedEnd));
525 return result;
526}
527
528QStringList MinecraftInstance::processMinecraftArgs(
529 AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin) const

Callers 1

processMinecraftArgsMethod · 0.85

Calls 4

nextMethod · 0.80
appendMethod · 0.80
endMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected