MCPcopy Create free account
hub / github.com/KDE/kdevelop / splitWithEscaping

Function splitWithEscaping

kdevplatform/util/kdevstringhandler.cpp:38–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38QStringList splitWithEscaping(const QString& input, QChar splitchar, QChar escapechar)
39{
40 enum State { Normal, SeenEscape } state;
41
42 state = Normal;
43
44 QStringList result;
45 QString currentstring;
46 for (const QChar c : input) {
47 switch (state) {
48 case Normal:
49 if (c == escapechar) {
50 state = SeenEscape;
51 } else if (c == splitchar) {
52 result << currentstring;
53 currentstring.clear();
54 } else {
55 currentstring += c;
56 }
57 break;
58 case SeenEscape:
59 currentstring += c;
60 state = Normal;
61 break;
62 }
63 }
64
65 if (!currentstring.isEmpty()) {
66 result << currentstring;
67 }
68 return result;
69}
70
71QVariant stringToQVariant(const QString& s)
72{

Callers 6

splitPathMethod · 0.85
validateMethod · 0.85
itemPathMethod · 0.85
currentItemMethod · 0.85
suggestionTriggeredMethod · 0.85
currentItemPathMethod · 0.85

Calls 2

clearMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected