MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / replaceTokensIn

Function replaceTokensIn

launcher/minecraft/MinecraftInstance.cpp:636–656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

634}
635
636static QString replaceTokensIn(QString text, QMap<QString, QString> with)
637{
638 // TODO: does this still work??
639 QString result;
640 QRegularExpression token_regexp("\\$\\{(.+)\\}", QRegularExpression::InvertedGreedinessOption);
641 QStringList list;
642 QRegularExpressionMatchIterator i = token_regexp.globalMatch(text);
643 int lastCapturedEnd = 0;
644 while (i.hasNext()) {
645 QRegularExpressionMatch match = i.next();
646 result.append(text.mid(lastCapturedEnd, match.capturedStart()));
647 QString key = match.captured(1);
648 auto iter = with.find(key);
649 if (iter != with.end()) {
650 result.append(*iter);
651 }
652 lastCapturedEnd = match.capturedEnd();
653 }
654 result.append(text.mid(lastCapturedEnd));
655 return result;
656}
657
658QStringList MinecraftInstance::processMinecraftArgs(AuthSessionPtr session, MinecraftTarget::Ptr targetToJoin) const
659{

Callers 1

processMinecraftArgsMethod · 0.85

Calls 2

appendMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected