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

Method trim

plugins/astyle/3rdparty/libastyle/ASBeautifier.cpp:1469–1486  ·  view source on GitHub ↗

* trim removes the white space surrounding a line. * * @return the trimmed line. * @param str the line to trim. */

Source from the content-addressed store, hash-verified

1467 * @param str the line to trim.
1468 */
1469string ASBeautifier::trim(const string& str) const
1470{
1471 int start = 0;
1472 int end = str.length() - 1;
1473
1474 while (start < end && isWhiteSpace(str[start]))
1475 start++;
1476
1477 while (start <= end && isWhiteSpace(str[end]))
1478 end--;
1479
1480 // don't trim if it ends in a continuation
1481 if (end > -1 && str[end] == '\\')
1482 end = str.length() - 1;
1483
1484 string returnStr(str, start, end + 1 - start);
1485 return returnStr;
1486}
1487
1488/**
1489 * rtrim removes the white space from the end of a line.

Callers 1

Calls 1

lengthMethod · 0.45

Tested by

no test coverage detected