2017-12-17 00:01:42 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
namespace chatterino {
|
2018-03-31 13:44:15 +02:00
|
|
|
|
2018-06-04 12:23:23 +02:00
|
|
|
inline QString parseTagString(const QString &input)
|
2017-12-17 00:01:42 +01:00
|
|
|
{
|
|
|
|
QString output = input;
|
2017-12-17 00:39:27 +01:00
|
|
|
output.detach();
|
2017-12-17 00:01:42 +01:00
|
|
|
|
2018-06-05 16:29:06 +02:00
|
|
|
auto length = output.length();
|
2017-12-17 00:01:42 +01:00
|
|
|
|
2018-06-05 16:29:06 +02:00
|
|
|
for (int i = 0; i < length - 1; i++) {
|
2017-12-17 00:39:27 +01:00
|
|
|
if (output[i] == '\\') {
|
|
|
|
QChar c = output[i + 1];
|
|
|
|
|
2017-12-17 00:56:33 +01:00
|
|
|
switch (c.cell()) {
|
|
|
|
case 'n': {
|
2018-06-05 16:29:06 +02:00
|
|
|
output.replace(i, 2, '\n');
|
2017-12-17 00:56:33 +01:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case 'r': {
|
2018-06-05 16:29:06 +02:00
|
|
|
output.replace(i, 2, '\r');
|
2017-12-17 00:56:33 +01:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case 's': {
|
2018-06-05 16:29:06 +02:00
|
|
|
output.replace(i, 2, ' ');
|
2017-12-17 00:56:33 +01:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case '\\': {
|
2018-06-05 16:29:06 +02:00
|
|
|
output.replace(i, 2, '\\');
|
2017-12-17 00:56:33 +01:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case ':': {
|
2018-06-05 16:29:06 +02:00
|
|
|
output.replace(i, 2, ';');
|
2017-12-17 00:56:33 +01:00
|
|
|
} break;
|
|
|
|
|
|
|
|
default: {
|
2018-06-05 16:29:06 +02:00
|
|
|
output.remove(i, 1);
|
2017-12-17 00:56:33 +01:00
|
|
|
} break;
|
2017-12-17 00:39:27 +01:00
|
|
|
}
|
2017-12-17 00:56:33 +01:00
|
|
|
|
2017-12-17 00:39:27 +01:00
|
|
|
i++;
|
2018-06-05 16:29:06 +02:00
|
|
|
length--;
|
2017-12-17 00:39:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-31 13:44:15 +02:00
|
|
|
return output;
|
2017-12-17 00:01:42 +01:00
|
|
|
}
|
2018-03-31 13:44:15 +02:00
|
|
|
|
2017-12-17 00:01:42 +01:00
|
|
|
} // namespace chatterino
|