MCPcopy Create free account
hub / github.com/RetroShare/RetroShare / string_unescape

Function string_unescape

retroshare-gui/src/util/stringutil.cpp:170–190  ·  view source on GitHub ↗

Given a quoted string str , this function returns an unquoted, * unescaped string. str must start and end with an unescaped quote. */

Source from the content-addressed store, hash-verified

168/** Given a quoted string <b>str</b>, this function returns an unquoted,
169 * unescaped string. <b>str</b> must start and end with an unescaped quote. */
170QString
171string_unescape(const QString &str, bool *ok)
172{
173 QString out;
174
175 /* The string must start and end with an unescaped dquote */
176 if (str.length() < 2 || !str.startsWith("\"") || !str.endsWith("\"") ||
177 (str.endsWith("\\\"") && !str.endsWith("\\\\\""))) {
178 if (ok)
179 *ok = false;
180 return QString();
181 }
182 for (int i = 1; i < str.length()-1; i++) {
183 if (str[i] == '\\')
184 i++;
185 out.append(str[i]);
186 }
187 if (ok)
188 *ok = true;
189 return out;
190}
191
192/** Parses a series of space-separated key[=value|="value"] tokens from
193 * <b>str</b> and returns the mappings in a QHash. If <b>str</b> was unable

Callers 2

string_parse_keyvalsFunction · 0.85
string_parse_argumentsFunction · 0.85

Calls 2

appendMethod · 0.80
QStringClass · 0.70

Tested by

no test coverage detected