summaryrefslogtreecommitdiffstats
path: root/src/Util.cpp
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2015-10-13 15:33:22 +0200
committerMarkus Mittendrein <git@maxmitti.tk>2015-10-13 15:33:22 +0200
commit1f6b9d308650b702cdfe49b7540bef4b3a4fc9f9 (patch)
treeac6775440f54478148397b0c499dd894c49a8c7f /src/Util.cpp
parent2edcec94e9e3f55313d4aa6d784e52ce37f1ba0e (diff)
downloadmanager-1f6b9d308650b702cdfe49b7540bef4b3a4fc9f9.tar.gz
manager-1f6b9d308650b702cdfe49b7540bef4b3a4fc9f9.zip
Correctly escape ClientInfo and ScenarioSettings
Diffstat (limited to 'src/Util.cpp')
-rw-r--r--src/Util.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/Util.cpp b/src/Util.cpp
index 8b5bc67..014f1f8 100644
--- a/src/Util.cpp
+++ b/src/Util.cpp
@@ -82,5 +82,54 @@ namespace Util {
return ret;
}
+ QString joinEscape(const QStringList &list, const QChar joinChar, const QChar escapeChar)
+ {
+ QString ret;
+ bool first = true;
+ foreach(const QString& part, list)
+ {
+ if(!first)
+ {
+ ret.append(joinChar);
+ }
+ else
+ {
+ first = false;
+ }
+ ret.append(escape(part, escapeChar, joinChar));
+ }
+ return ret;
+ }
+
+ QStringList splitEscaped(const QString &joined, const QChar splitChar, const QChar escapeChar)
+ {
+ QStringList ret;
+
+ int partPos = 0;
+ bool escaped = false;
+ for(int i = 0; i < joined.length(); ++i)
+ {
+ QChar c = joined.at(i);
+ if(!escaped)
+ {
+ if(c == escapeChar)
+ {
+ escaped = true;
+ }
+ else if(c == splitChar)
+ {
+ ret.append(Util::unescape(joined.mid(partPos, i - partPos), escapeChar));
+ partPos = i + 1;
+ }
+ }
+ else
+ {
+ escaped = false;
+ }
+ }
+ ret.append(Util::unescape(joined.mid(partPos), escapeChar));
+
+ return ret;
+ }
}