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

Method parseStringLiteral

plugins/debuggercommon/mi/miparser.cpp:311–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309}
310
311QString MIParser::parseStringLiteral()
312{
313 const auto message = QString::fromUtf8(m_lex->currentTokenText());
314 const int length = message.length();
315
316 QString message2;
317 message2.reserve(length);
318 // The [1,length-1] range removes quotes without extra
319 // call to 'mid'
320 for(int i = 1, e = length-1; i != e; ++i)
321 {
322 int translated = -1;
323 if (message[i] == QLatin1Char('\\')) {
324 if (i+1 < length)
325 {
326 // TODO: implement all the other escapes, maybe
327 if (message[i+1] == QLatin1Char('n')) {
328 translated = '\n';
329 }
330 else if (message[i+1] == QLatin1Char('\\')) {
331 translated = '\\';
332 }
333 else if (message[i+1] == QLatin1Char('"')) {
334 translated = '"';
335 }
336 else if (message[i+1] == QLatin1Char('t')) {
337 translated = '\t';
338 }
339 else if (message[i+1] == QLatin1Char('r')) {
340 translated = '\r';
341 }
342 }
343 }
344
345 if (translated != -1)
346 {
347 message2.append(QLatin1Char(translated));
348 ++i;
349 }
350 else
351 {
352 message2.append(message[i]);
353 }
354 }
355
356 m_lex->nextToken();
357 return message2;
358}
359

Callers

nothing calls this directly

Calls 5

currentTokenTextMethod · 0.80
lengthMethod · 0.45
reserveMethod · 0.45
appendMethod · 0.45
nextTokenMethod · 0.45

Tested by

no test coverage detected